babylon.gui.js 751 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** E:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math.vector");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. _this._defaultMousePointerId = 0;
  516. /** @hidden */
  517. _this._numLayoutCalls = 0;
  518. /** @hidden */
  519. _this._numRenderCalls = 0;
  520. /**
  521. * Define type to string to ensure compatibility across browsers
  522. * Safari doesn't support DataTransfer constructor
  523. */
  524. _this._clipboardData = "";
  525. /**
  526. * Observable event triggered each time an clipboard event is received from the rendering canvas
  527. */
  528. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  529. /**
  530. * Observable event triggered each time a pointer down is intercepted by a control
  531. */
  532. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  533. /**
  534. * Observable event triggered before layout is evaluated
  535. */
  536. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  537. /**
  538. * Observable event triggered after the layout was evaluated
  539. */
  540. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  541. /**
  542. * Observable event triggered before the texture is rendered
  543. */
  544. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  545. /**
  546. * Observable event triggered after the texture was rendered
  547. */
  548. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  549. /**
  550. * Gets or sets a boolean defining if alpha is stored as premultiplied
  551. */
  552. _this.premulAlpha = false;
  553. _this._useInvalidateRectOptimization = true;
  554. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  555. _this._invalidatedRectangle = null;
  556. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  557. /** @hidden */
  558. _this.onClipboardCopy = function (rawEvt) {
  559. var evt = rawEvt;
  560. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  561. _this.onClipboardObservable.notifyObservers(ev);
  562. evt.preventDefault();
  563. };
  564. /** @hidden */
  565. _this.onClipboardCut = function (rawEvt) {
  566. var evt = rawEvt;
  567. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  568. _this.onClipboardObservable.notifyObservers(ev);
  569. evt.preventDefault();
  570. };
  571. /** @hidden */
  572. _this.onClipboardPaste = function (rawEvt) {
  573. var evt = rawEvt;
  574. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  575. _this.onClipboardObservable.notifyObservers(ev);
  576. evt.preventDefault();
  577. };
  578. scene = _this.getScene();
  579. if (!scene || !_this._texture) {
  580. return _this;
  581. }
  582. _this._rootElement = scene.getEngine().getInputElement();
  583. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  584. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  585. if (!_this._focusedControl) {
  586. return;
  587. }
  588. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  589. _this._focusedControl.processKeyboard(info.event);
  590. }
  591. info.skipOnPointerObservable = true;
  592. });
  593. _this._rootContainer._link(_this);
  594. _this.hasAlpha = true;
  595. if (!width || !height) {
  596. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  597. _this._onResize();
  598. }
  599. _this._texture.isReady = true;
  600. return _this;
  601. }
  602. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  603. /** Gets the number of layout calls made the last time the ADT has been rendered */
  604. get: function () {
  605. return this._numLayoutCalls;
  606. },
  607. enumerable: true,
  608. configurable: true
  609. });
  610. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  611. /** Gets the number of render calls made the last time the ADT has been rendered */
  612. get: function () {
  613. return this._numRenderCalls;
  614. },
  615. enumerable: true,
  616. configurable: true
  617. });
  618. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  619. /**
  620. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  621. * Useful when you want more antialiasing
  622. */
  623. get: function () {
  624. return this._renderScale;
  625. },
  626. set: function (value) {
  627. if (value === this._renderScale) {
  628. return;
  629. }
  630. this._renderScale = value;
  631. this._onResize();
  632. },
  633. enumerable: true,
  634. configurable: true
  635. });
  636. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  637. /** Gets or sets the background color */
  638. get: function () {
  639. return this._background;
  640. },
  641. set: function (value) {
  642. if (this._background === value) {
  643. return;
  644. }
  645. this._background = value;
  646. this.markAsDirty();
  647. },
  648. enumerable: true,
  649. configurable: true
  650. });
  651. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  652. /**
  653. * Gets or sets the ideal width used to design controls.
  654. * The GUI will then rescale everything accordingly
  655. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  656. */
  657. get: function () {
  658. return this._idealWidth;
  659. },
  660. set: function (value) {
  661. if (this._idealWidth === value) {
  662. return;
  663. }
  664. this._idealWidth = value;
  665. this.markAsDirty();
  666. this._rootContainer._markAllAsDirty();
  667. },
  668. enumerable: true,
  669. configurable: true
  670. });
  671. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  672. /**
  673. * Gets or sets the ideal height used to design controls.
  674. * The GUI will then rescale everything accordingly
  675. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  676. */
  677. get: function () {
  678. return this._idealHeight;
  679. },
  680. set: function (value) {
  681. if (this._idealHeight === value) {
  682. return;
  683. }
  684. this._idealHeight = value;
  685. this.markAsDirty();
  686. this._rootContainer._markAllAsDirty();
  687. },
  688. enumerable: true,
  689. configurable: true
  690. });
  691. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  692. /**
  693. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  694. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  695. */
  696. get: function () {
  697. return this._useSmallestIdeal;
  698. },
  699. set: function (value) {
  700. if (this._useSmallestIdeal === value) {
  701. return;
  702. }
  703. this._useSmallestIdeal = value;
  704. this.markAsDirty();
  705. this._rootContainer._markAllAsDirty();
  706. },
  707. enumerable: true,
  708. configurable: true
  709. });
  710. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  711. /**
  712. * Gets or sets a boolean indicating if adaptive scaling must be used
  713. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  714. */
  715. get: function () {
  716. return this._renderAtIdealSize;
  717. },
  718. set: function (value) {
  719. if (this._renderAtIdealSize === value) {
  720. return;
  721. }
  722. this._renderAtIdealSize = value;
  723. this._onResize();
  724. },
  725. enumerable: true,
  726. configurable: true
  727. });
  728. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  729. /**
  730. * Gets the ratio used when in "ideal mode"
  731. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  732. * */
  733. get: function () {
  734. var rwidth = 0;
  735. var rheight = 0;
  736. if (this._idealWidth) {
  737. rwidth = (this.getSize().width) / this._idealWidth;
  738. }
  739. if (this._idealHeight) {
  740. rheight = (this.getSize().height) / this._idealHeight;
  741. }
  742. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  743. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  744. }
  745. if (this._idealWidth) { // horizontal
  746. return rwidth;
  747. }
  748. if (this._idealHeight) { // vertical
  749. return rheight;
  750. }
  751. return 1;
  752. },
  753. enumerable: true,
  754. configurable: true
  755. });
  756. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  757. /**
  758. * Gets the underlying layer used to render the texture when in fullscreen mode
  759. */
  760. get: function () {
  761. return this._layerToDispose;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  767. /**
  768. * Gets the root container control
  769. */
  770. get: function () {
  771. return this._rootContainer;
  772. },
  773. enumerable: true,
  774. configurable: true
  775. });
  776. /**
  777. * Returns an array containing the root container.
  778. * This is mostly used to let the Inspector introspects the ADT
  779. * @returns an array containing the rootContainer
  780. */
  781. AdvancedDynamicTexture.prototype.getChildren = function () {
  782. return [this._rootContainer];
  783. };
  784. /**
  785. * Will return all controls that are inside this texture
  786. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  787. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  788. * @return all child controls
  789. */
  790. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  791. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  792. };
  793. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  794. /**
  795. * Gets or sets the current focused control
  796. */
  797. get: function () {
  798. return this._focusedControl;
  799. },
  800. set: function (control) {
  801. if (this._focusedControl == control) {
  802. return;
  803. }
  804. if (this._focusedControl) {
  805. this._focusedControl.onBlur();
  806. }
  807. if (control) {
  808. control.onFocus();
  809. }
  810. this._focusedControl = control;
  811. },
  812. enumerable: true,
  813. configurable: true
  814. });
  815. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  816. /**
  817. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  818. */
  819. get: function () {
  820. if (!this.layer) {
  821. return true;
  822. }
  823. return (!this.layer.isBackground);
  824. },
  825. set: function (value) {
  826. if (!this.layer) {
  827. return;
  828. }
  829. if (this.layer.isBackground === !value) {
  830. return;
  831. }
  832. this.layer.isBackground = !value;
  833. },
  834. enumerable: true,
  835. configurable: true
  836. });
  837. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  838. /**
  839. * Gets or set information about clipboardData
  840. */
  841. get: function () {
  842. return this._clipboardData;
  843. },
  844. set: function (value) {
  845. this._clipboardData = value;
  846. },
  847. enumerable: true,
  848. configurable: true
  849. });
  850. /**
  851. * Get the current class name of the texture useful for serialization or dynamic coding.
  852. * @returns "AdvancedDynamicTexture"
  853. */
  854. AdvancedDynamicTexture.prototype.getClassName = function () {
  855. return "AdvancedDynamicTexture";
  856. };
  857. /**
  858. * Function used to execute a function on all controls
  859. * @param func defines the function to execute
  860. * @param container defines the container where controls belong. If null the root container will be used
  861. */
  862. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  863. if (!container) {
  864. container = this._rootContainer;
  865. }
  866. func(container);
  867. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  868. var child = _a[_i];
  869. if (child.children) {
  870. this.executeOnAllControls(func, child);
  871. continue;
  872. }
  873. func(child);
  874. }
  875. };
  876. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  877. /**
  878. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  879. */
  880. get: function () {
  881. return this._useInvalidateRectOptimization;
  882. },
  883. set: function (value) {
  884. this._useInvalidateRectOptimization = value;
  885. },
  886. enumerable: true,
  887. configurable: true
  888. });
  889. /**
  890. * Invalidates a rectangle area on the gui texture
  891. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  892. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  894. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  895. */
  896. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  897. if (!this._useInvalidateRectOptimization) {
  898. return;
  899. }
  900. if (!this._invalidatedRectangle) {
  901. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  902. }
  903. else {
  904. // Compute intersection
  905. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  906. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  907. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  908. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  909. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  910. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  911. }
  912. };
  913. /**
  914. * Marks the texture as dirty forcing a complete update
  915. */
  916. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  917. this._isDirty = true;
  918. };
  919. /**
  920. * Helper function used to create a new style
  921. * @returns a new style
  922. * @see http://doc.babylonjs.com/how_to/gui#styles
  923. */
  924. AdvancedDynamicTexture.prototype.createStyle = function () {
  925. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  926. };
  927. /**
  928. * Adds a new control to the root container
  929. * @param control defines the control to add
  930. * @returns the current texture
  931. */
  932. AdvancedDynamicTexture.prototype.addControl = function (control) {
  933. this._rootContainer.addControl(control);
  934. return this;
  935. };
  936. /**
  937. * Removes a control from the root container
  938. * @param control defines the control to remove
  939. * @returns the current texture
  940. */
  941. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  942. this._rootContainer.removeControl(control);
  943. return this;
  944. };
  945. /**
  946. * Release all resources
  947. */
  948. AdvancedDynamicTexture.prototype.dispose = function () {
  949. var scene = this.getScene();
  950. if (!scene) {
  951. return;
  952. }
  953. this._rootElement = null;
  954. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  955. if (this._resizeObserver) {
  956. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  957. }
  958. if (this._pointerMoveObserver) {
  959. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  960. }
  961. if (this._pointerObserver) {
  962. scene.onPointerObservable.remove(this._pointerObserver);
  963. }
  964. if (this._preKeyboardObserver) {
  965. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  966. }
  967. if (this._canvasPointerOutObserver) {
  968. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  969. }
  970. if (this._layerToDispose) {
  971. this._layerToDispose.texture = null;
  972. this._layerToDispose.dispose();
  973. this._layerToDispose = null;
  974. }
  975. this._rootContainer.dispose();
  976. this.onClipboardObservable.clear();
  977. this.onControlPickedObservable.clear();
  978. this.onBeginRenderObservable.clear();
  979. this.onEndRenderObservable.clear();
  980. this.onBeginLayoutObservable.clear();
  981. this.onEndLayoutObservable.clear();
  982. _super.prototype.dispose.call(this);
  983. };
  984. AdvancedDynamicTexture.prototype._onResize = function () {
  985. var scene = this.getScene();
  986. if (!scene) {
  987. return;
  988. }
  989. // Check size
  990. var engine = scene.getEngine();
  991. var textureSize = this.getSize();
  992. var renderWidth = engine.getRenderWidth() * this._renderScale;
  993. var renderHeight = engine.getRenderHeight() * this._renderScale;
  994. if (this._renderAtIdealSize) {
  995. if (this._idealWidth) {
  996. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  997. renderWidth = this._idealWidth;
  998. }
  999. else if (this._idealHeight) {
  1000. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1001. renderHeight = this._idealHeight;
  1002. }
  1003. }
  1004. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1005. this.scaleTo(renderWidth, renderHeight);
  1006. this.markAsDirty();
  1007. if (this._idealWidth || this._idealHeight) {
  1008. this._rootContainer._markAllAsDirty();
  1009. }
  1010. }
  1011. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1012. };
  1013. /** @hidden */
  1014. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1015. var engine = scene.getEngine();
  1016. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1017. };
  1018. /**
  1019. * Get screen coordinates for a vector3
  1020. * @param position defines the position to project
  1021. * @param worldMatrix defines the world matrix to use
  1022. * @returns the projected position
  1023. */
  1024. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1025. var scene = this.getScene();
  1026. if (!scene) {
  1027. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1028. }
  1029. var globalViewport = this._getGlobalViewport(scene);
  1030. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1031. projectedPosition.scaleInPlace(this.renderScale);
  1032. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1033. };
  1034. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1035. if (this._layerToDispose) {
  1036. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1037. return;
  1038. }
  1039. }
  1040. if (this._isFullscreen && this._linkedControls.length) {
  1041. var scene = this.getScene();
  1042. if (!scene) {
  1043. return;
  1044. }
  1045. var globalViewport = this._getGlobalViewport(scene);
  1046. var _loop_1 = function (control) {
  1047. if (!control.isVisible) {
  1048. return "continue";
  1049. }
  1050. var mesh = control._linkedMesh;
  1051. if (!mesh || mesh.isDisposed()) {
  1052. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1053. control.linkWithMesh(null);
  1054. });
  1055. return "continue";
  1056. }
  1057. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1058. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1059. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1060. control.notRenderable = true;
  1061. return "continue";
  1062. }
  1063. control.notRenderable = false;
  1064. // Account for RenderScale.
  1065. projectedPosition.scaleInPlace(this_1.renderScale);
  1066. control._moveToProjectedPosition(projectedPosition);
  1067. };
  1068. var this_1 = this;
  1069. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1070. var control = _a[_i];
  1071. _loop_1(control);
  1072. }
  1073. }
  1074. if (!this._isDirty && !this._rootContainer.isDirty) {
  1075. return;
  1076. }
  1077. this._isDirty = false;
  1078. this._render();
  1079. this.update(true, this.premulAlpha);
  1080. };
  1081. AdvancedDynamicTexture.prototype._render = function () {
  1082. var textureSize = this.getSize();
  1083. var renderWidth = textureSize.width;
  1084. var renderHeight = textureSize.height;
  1085. var context = this.getContext();
  1086. context.font = "18px Arial";
  1087. context.strokeStyle = "white";
  1088. // Layout
  1089. this.onBeginLayoutObservable.notifyObservers(this);
  1090. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1091. this._numLayoutCalls = 0;
  1092. this._rootContainer._layout(measure, context);
  1093. this.onEndLayoutObservable.notifyObservers(this);
  1094. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1095. // Clear
  1096. if (this._invalidatedRectangle) {
  1097. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1098. }
  1099. else {
  1100. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1101. }
  1102. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1103. if (this._background) {
  1104. context.save();
  1105. context.fillStyle = this._background;
  1106. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1107. context.restore();
  1108. }
  1109. // Render
  1110. this.onBeginRenderObservable.notifyObservers(this);
  1111. this._numRenderCalls = 0;
  1112. this._rootContainer._render(context, this._invalidatedRectangle);
  1113. this.onEndRenderObservable.notifyObservers(this);
  1114. this._invalidatedRectangle = null;
  1115. };
  1116. /** @hidden */
  1117. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1118. if (this._rootElement) {
  1119. this._rootElement.style.cursor = cursor;
  1120. this._cursorChanged = true;
  1121. }
  1122. };
  1123. /** @hidden */
  1124. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1125. this._lastControlDown[pointerId] = control;
  1126. this.onControlPickedObservable.notifyObservers(control);
  1127. };
  1128. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1129. var scene = this.getScene();
  1130. if (!scene) {
  1131. return;
  1132. }
  1133. var engine = scene.getEngine();
  1134. var textureSize = this.getSize();
  1135. if (this._isFullscreen) {
  1136. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1137. var viewport = camera.viewport;
  1138. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1139. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1140. }
  1141. if (this._capturingControl[pointerId]) {
  1142. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1143. return;
  1144. }
  1145. this._cursorChanged = false;
  1146. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1147. this._changeCursor("");
  1148. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1149. if (this._lastControlOver[pointerId]) {
  1150. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1151. delete this._lastControlOver[pointerId];
  1152. }
  1153. }
  1154. }
  1155. if (!this._cursorChanged) {
  1156. this._changeCursor("");
  1157. }
  1158. this._manageFocus();
  1159. };
  1160. /** @hidden */
  1161. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1162. for (var pointerId in list) {
  1163. if (!list.hasOwnProperty(pointerId)) {
  1164. continue;
  1165. }
  1166. var lastControlOver = list[pointerId];
  1167. if (lastControlOver === control) {
  1168. delete list[pointerId];
  1169. }
  1170. }
  1171. };
  1172. /** @hidden */
  1173. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1174. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1175. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1176. };
  1177. /** Attach to all scene events required to support pointer events */
  1178. AdvancedDynamicTexture.prototype.attach = function () {
  1179. var _this = this;
  1180. var scene = this.getScene();
  1181. if (!scene) {
  1182. return;
  1183. }
  1184. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1185. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1186. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1187. return;
  1188. }
  1189. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1190. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1191. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1192. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1193. return;
  1194. }
  1195. if (!scene) {
  1196. return;
  1197. }
  1198. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1199. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1200. }
  1201. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1202. var engine = scene.getEngine();
  1203. if (!camera) {
  1204. tempViewport.x = 0;
  1205. tempViewport.y = 0;
  1206. tempViewport.width = engine.getRenderWidth();
  1207. tempViewport.height = engine.getRenderHeight();
  1208. }
  1209. else {
  1210. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1211. }
  1212. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1213. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1214. _this._shouldBlockPointer = false;
  1215. // Do picking modifies _shouldBlockPointer
  1216. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1217. _this._doPicking(x, y, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1218. // Avoid overwriting a true skipOnPointerObservable to false
  1219. if (_this._shouldBlockPointer) {
  1220. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1221. }
  1222. });
  1223. this._attachToOnPointerOut(scene);
  1224. };
  1225. /**
  1226. * Register the clipboard Events onto the canvas
  1227. */
  1228. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1229. self.addEventListener("copy", this.onClipboardCopy, false);
  1230. self.addEventListener("cut", this.onClipboardCut, false);
  1231. self.addEventListener("paste", this.onClipboardPaste, false);
  1232. };
  1233. /**
  1234. * Unregister the clipboard Events from the canvas
  1235. */
  1236. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1237. self.removeEventListener("copy", this.onClipboardCopy);
  1238. self.removeEventListener("cut", this.onClipboardCut);
  1239. self.removeEventListener("paste", this.onClipboardPaste);
  1240. };
  1241. /**
  1242. * Connect the texture to a hosting mesh to enable interactions
  1243. * @param mesh defines the mesh to attach to
  1244. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1245. */
  1246. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1247. var _this = this;
  1248. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1249. var scene = this.getScene();
  1250. if (!scene) {
  1251. return;
  1252. }
  1253. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1254. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1255. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1256. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1257. return;
  1258. }
  1259. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1260. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1261. var uv = pi.pickInfo.getTextureCoordinates();
  1262. if (uv) {
  1263. var size = _this.getSize();
  1264. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1265. }
  1266. }
  1267. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1268. if (_this._lastControlDown[pointerId]) {
  1269. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1270. }
  1271. delete _this._lastControlDown[pointerId];
  1272. if (_this.focusedControl) {
  1273. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1274. var canMoveFocus = true;
  1275. if (friendlyControls) {
  1276. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1277. var control = friendlyControls_1[_i];
  1278. // Same host, no need to keep the focus
  1279. if (_this === control._host) {
  1280. continue;
  1281. }
  1282. // Different hosts
  1283. var otherHost = control._host;
  1284. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1285. canMoveFocus = false;
  1286. break;
  1287. }
  1288. }
  1289. }
  1290. if (canMoveFocus) {
  1291. _this.focusedControl = null;
  1292. }
  1293. }
  1294. }
  1295. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1296. if (_this._lastControlOver[pointerId]) {
  1297. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1298. }
  1299. delete _this._lastControlOver[pointerId];
  1300. }
  1301. });
  1302. mesh.enablePointerMoveEvents = supportPointerMove;
  1303. this._attachToOnPointerOut(scene);
  1304. };
  1305. /**
  1306. * Move the focus to a specific control
  1307. * @param control defines the control which will receive the focus
  1308. */
  1309. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1310. this.focusedControl = control;
  1311. this._lastPickedControl = control;
  1312. this._blockNextFocusCheck = true;
  1313. };
  1314. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1315. if (this._blockNextFocusCheck) {
  1316. this._blockNextFocusCheck = false;
  1317. this._lastPickedControl = this._focusedControl;
  1318. return;
  1319. }
  1320. // Focus management
  1321. if (this._focusedControl) {
  1322. if (this._focusedControl !== this._lastPickedControl) {
  1323. if (this._lastPickedControl.isFocusInvisible) {
  1324. return;
  1325. }
  1326. this.focusedControl = null;
  1327. }
  1328. }
  1329. };
  1330. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1331. var _this = this;
  1332. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1333. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1334. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1335. }
  1336. delete _this._lastControlOver[pointerEvent.pointerId];
  1337. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1338. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1339. delete _this._lastControlDown[pointerEvent.pointerId];
  1340. }
  1341. });
  1342. };
  1343. // Statics
  1344. /**
  1345. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1346. * @param mesh defines the mesh which will receive the texture
  1347. * @param width defines the texture width (1024 by default)
  1348. * @param height defines the texture height (1024 by default)
  1349. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1350. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1351. * @returns a new AdvancedDynamicTexture
  1352. */
  1353. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1354. if (width === void 0) { width = 1024; }
  1355. if (height === void 0) { height = 1024; }
  1356. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1357. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1358. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1359. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1360. material.backFaceCulling = false;
  1361. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1362. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1363. if (onlyAlphaTesting) {
  1364. material.diffuseTexture = result;
  1365. material.emissiveTexture = result;
  1366. result.hasAlpha = true;
  1367. }
  1368. else {
  1369. material.emissiveTexture = result;
  1370. material.opacityTexture = result;
  1371. }
  1372. mesh.material = material;
  1373. result.attachToMesh(mesh, supportPointerMove);
  1374. return result;
  1375. };
  1376. /**
  1377. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1378. * In this mode the texture will rely on a layer for its rendering.
  1379. * This allows it to be treated like any other layer.
  1380. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1381. * LayerMask is set through advancedTexture.layer.layerMask
  1382. * @param name defines name for the texture
  1383. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1384. * @param scene defines the hsoting scene
  1385. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1386. * @returns a new AdvancedDynamicTexture
  1387. */
  1388. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1389. if (foreground === void 0) { foreground = true; }
  1390. if (scene === void 0) { scene = null; }
  1391. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1392. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1393. // Display
  1394. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1395. layer.texture = result;
  1396. result._layerToDispose = layer;
  1397. result._isFullscreen = true;
  1398. // Attach
  1399. result.attach();
  1400. return result;
  1401. };
  1402. return AdvancedDynamicTexture;
  1403. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1404. /***/ }),
  1405. /***/ "./2D/controls/button.ts":
  1406. /*!*******************************!*\
  1407. !*** ./2D/controls/button.ts ***!
  1408. \*******************************/
  1409. /*! exports provided: Button */
  1410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1411. "use strict";
  1412. __webpack_require__.r(__webpack_exports__);
  1413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1414. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1415. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1416. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1417. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1418. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1419. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  1420. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1421. /**
  1422. * Class used to create 2D buttons
  1423. */
  1424. var Button = /** @class */ (function (_super) {
  1425. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1426. /**
  1427. * Creates a new Button
  1428. * @param name defines the name of the button
  1429. */
  1430. function Button(name) {
  1431. var _this = _super.call(this, name) || this;
  1432. _this.name = name;
  1433. /**
  1434. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1435. */
  1436. _this.delegatePickingToChildren = false;
  1437. _this.thickness = 1;
  1438. _this.isPointerBlocker = true;
  1439. var alphaStore = null;
  1440. _this.pointerEnterAnimation = function () {
  1441. alphaStore = _this.alpha;
  1442. _this.alpha -= 0.1;
  1443. };
  1444. _this.pointerOutAnimation = function () {
  1445. if (alphaStore !== null) {
  1446. _this.alpha = alphaStore;
  1447. }
  1448. };
  1449. _this.pointerDownAnimation = function () {
  1450. _this.scaleX -= 0.05;
  1451. _this.scaleY -= 0.05;
  1452. };
  1453. _this.pointerUpAnimation = function () {
  1454. _this.scaleX += 0.05;
  1455. _this.scaleY += 0.05;
  1456. };
  1457. return _this;
  1458. }
  1459. Object.defineProperty(Button.prototype, "image", {
  1460. /**
  1461. * Returns the image part of the button (if any)
  1462. */
  1463. get: function () {
  1464. return this._image;
  1465. },
  1466. enumerable: true,
  1467. configurable: true
  1468. });
  1469. Object.defineProperty(Button.prototype, "textBlock", {
  1470. /**
  1471. * Returns the image part of the button (if any)
  1472. */
  1473. get: function () {
  1474. return this._textBlock;
  1475. },
  1476. enumerable: true,
  1477. configurable: true
  1478. });
  1479. Button.prototype._getTypeName = function () {
  1480. return "Button";
  1481. };
  1482. // While being a container, the button behaves like a control.
  1483. /** @hidden */
  1484. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1485. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1486. return false;
  1487. }
  1488. if (!_super.prototype.contains.call(this, x, y)) {
  1489. return false;
  1490. }
  1491. if (this.delegatePickingToChildren) {
  1492. var contains = false;
  1493. for (var index = this._children.length - 1; index >= 0; index--) {
  1494. var child = this._children[index];
  1495. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1496. contains = true;
  1497. break;
  1498. }
  1499. }
  1500. if (!contains) {
  1501. return false;
  1502. }
  1503. }
  1504. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  1505. return true;
  1506. };
  1507. /** @hidden */
  1508. Button.prototype._onPointerEnter = function (target) {
  1509. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1510. return false;
  1511. }
  1512. if (this.pointerEnterAnimation) {
  1513. this.pointerEnterAnimation();
  1514. }
  1515. return true;
  1516. };
  1517. /** @hidden */
  1518. Button.prototype._onPointerOut = function (target, force) {
  1519. if (force === void 0) { force = false; }
  1520. if (this.pointerOutAnimation) {
  1521. this.pointerOutAnimation();
  1522. }
  1523. _super.prototype._onPointerOut.call(this, target, force);
  1524. };
  1525. /** @hidden */
  1526. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1527. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1528. return false;
  1529. }
  1530. if (this.pointerDownAnimation) {
  1531. this.pointerDownAnimation();
  1532. }
  1533. return true;
  1534. };
  1535. /** @hidden */
  1536. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1537. if (this.pointerUpAnimation) {
  1538. this.pointerUpAnimation();
  1539. }
  1540. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1541. };
  1542. // Statics
  1543. /**
  1544. * Creates a new button made with an image and a text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. Button.CreateImageButton = function (name, text, imageUrl) {
  1551. var result = new Button(name);
  1552. // Adding text
  1553. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1554. textBlock.textWrapping = true;
  1555. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1556. textBlock.paddingLeft = "20%";
  1557. result.addControl(textBlock);
  1558. // Adding image
  1559. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1560. iconImage.width = "20%";
  1561. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1562. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1563. result.addControl(iconImage);
  1564. // Store
  1565. result._image = iconImage;
  1566. result._textBlock = textBlock;
  1567. return result;
  1568. };
  1569. /**
  1570. * Creates a new button made with an image
  1571. * @param name defines the name of the button
  1572. * @param imageUrl defines the url of the image
  1573. * @returns a new Button
  1574. */
  1575. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1576. var result = new Button(name);
  1577. // Adding image
  1578. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1579. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1580. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1581. result.addControl(iconImage);
  1582. // Store
  1583. result._image = iconImage;
  1584. return result;
  1585. };
  1586. /**
  1587. * Creates a new button made with a text
  1588. * @param name defines the name of the button
  1589. * @param text defines the text of the button
  1590. * @returns a new Button
  1591. */
  1592. Button.CreateSimpleButton = function (name, text) {
  1593. var result = new Button(name);
  1594. // Adding text
  1595. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1596. textBlock.textWrapping = true;
  1597. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1598. result.addControl(textBlock);
  1599. // Store
  1600. result._textBlock = textBlock;
  1601. return result;
  1602. };
  1603. /**
  1604. * Creates a new button made with an image and a centered text
  1605. * @param name defines the name of the button
  1606. * @param text defines the text of the button
  1607. * @param imageUrl defines the url of the image
  1608. * @returns a new Button
  1609. */
  1610. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1611. var result = new Button(name);
  1612. // Adding image
  1613. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1614. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1615. result.addControl(iconImage);
  1616. // Adding text
  1617. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1618. textBlock.textWrapping = true;
  1619. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1620. result.addControl(textBlock);
  1621. // Store
  1622. result._image = iconImage;
  1623. result._textBlock = textBlock;
  1624. return result;
  1625. };
  1626. return Button;
  1627. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1628. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1629. /***/ }),
  1630. /***/ "./2D/controls/checkbox.ts":
  1631. /*!*********************************!*\
  1632. !*** ./2D/controls/checkbox.ts ***!
  1633. \*********************************/
  1634. /*! exports provided: Checkbox */
  1635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1636. "use strict";
  1637. __webpack_require__.r(__webpack_exports__);
  1638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1639. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1640. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  1641. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1642. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1643. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1644. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1645. /**
  1646. * Class used to represent a 2D checkbox
  1647. */
  1648. var Checkbox = /** @class */ (function (_super) {
  1649. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1650. /**
  1651. * Creates a new CheckBox
  1652. * @param name defines the control name
  1653. */
  1654. function Checkbox(name) {
  1655. var _this = _super.call(this, name) || this;
  1656. _this.name = name;
  1657. _this._isChecked = false;
  1658. _this._background = "black";
  1659. _this._checkSizeRatio = 0.8;
  1660. _this._thickness = 1;
  1661. /**
  1662. * Observable raised when isChecked property changes
  1663. */
  1664. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1665. _this.isPointerBlocker = true;
  1666. return _this;
  1667. }
  1668. Object.defineProperty(Checkbox.prototype, "thickness", {
  1669. /** Gets or sets border thickness */
  1670. get: function () {
  1671. return this._thickness;
  1672. },
  1673. set: function (value) {
  1674. if (this._thickness === value) {
  1675. return;
  1676. }
  1677. this._thickness = value;
  1678. this._markAsDirty();
  1679. },
  1680. enumerable: true,
  1681. configurable: true
  1682. });
  1683. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1684. /** Gets or sets a value indicating the ratio between overall size and check size */
  1685. get: function () {
  1686. return this._checkSizeRatio;
  1687. },
  1688. set: function (value) {
  1689. value = Math.max(Math.min(1, value), 0);
  1690. if (this._checkSizeRatio === value) {
  1691. return;
  1692. }
  1693. this._checkSizeRatio = value;
  1694. this._markAsDirty();
  1695. },
  1696. enumerable: true,
  1697. configurable: true
  1698. });
  1699. Object.defineProperty(Checkbox.prototype, "background", {
  1700. /** Gets or sets background color */
  1701. get: function () {
  1702. return this._background;
  1703. },
  1704. set: function (value) {
  1705. if (this._background === value) {
  1706. return;
  1707. }
  1708. this._background = value;
  1709. this._markAsDirty();
  1710. },
  1711. enumerable: true,
  1712. configurable: true
  1713. });
  1714. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1715. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1716. get: function () {
  1717. return this._isChecked;
  1718. },
  1719. set: function (value) {
  1720. if (this._isChecked === value) {
  1721. return;
  1722. }
  1723. this._isChecked = value;
  1724. this._markAsDirty();
  1725. this.onIsCheckedChangedObservable.notifyObservers(value);
  1726. },
  1727. enumerable: true,
  1728. configurable: true
  1729. });
  1730. Checkbox.prototype._getTypeName = function () {
  1731. return "Checkbox";
  1732. };
  1733. /** @hidden */
  1734. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1735. context.save();
  1736. this._applyStates(context);
  1737. var actualWidth = this._currentMeasure.width - this._thickness;
  1738. var actualHeight = this._currentMeasure.height - this._thickness;
  1739. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1740. context.shadowColor = this.shadowColor;
  1741. context.shadowBlur = this.shadowBlur;
  1742. context.shadowOffsetX = this.shadowOffsetX;
  1743. context.shadowOffsetY = this.shadowOffsetY;
  1744. }
  1745. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1746. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1747. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1748. context.shadowBlur = 0;
  1749. context.shadowOffsetX = 0;
  1750. context.shadowOffsetY = 0;
  1751. }
  1752. if (this._isChecked) {
  1753. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1754. var offsetWidth = actualWidth * this._checkSizeRatio;
  1755. var offseHeight = actualHeight * this._checkSizeRatio;
  1756. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1757. }
  1758. context.strokeStyle = this.color;
  1759. context.lineWidth = this._thickness;
  1760. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1761. context.restore();
  1762. };
  1763. // Events
  1764. /** @hidden */
  1765. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1766. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1767. return false;
  1768. }
  1769. this.isChecked = !this.isChecked;
  1770. return true;
  1771. };
  1772. /**
  1773. * Utility function to easily create a checkbox with a header
  1774. * @param title defines the label to use for the header
  1775. * @param onValueChanged defines the callback to call when value changes
  1776. * @returns a StackPanel containing the checkbox and a textBlock
  1777. */
  1778. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1779. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1780. panel.isVertical = false;
  1781. panel.height = "30px";
  1782. var checkbox = new Checkbox();
  1783. checkbox.width = "20px";
  1784. checkbox.height = "20px";
  1785. checkbox.isChecked = true;
  1786. checkbox.color = "green";
  1787. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1788. panel.addControl(checkbox);
  1789. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1790. header.text = title;
  1791. header.width = "180px";
  1792. header.paddingLeft = "5px";
  1793. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1794. header.color = "white";
  1795. panel.addControl(header);
  1796. return panel;
  1797. };
  1798. return Checkbox;
  1799. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1800. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1801. /***/ }),
  1802. /***/ "./2D/controls/colorpicker.ts":
  1803. /*!************************************!*\
  1804. !*** ./2D/controls/colorpicker.ts ***!
  1805. \************************************/
  1806. /*! exports provided: ColorPicker */
  1807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1808. "use strict";
  1809. __webpack_require__.r(__webpack_exports__);
  1810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1811. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1812. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  1813. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1814. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1815. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1816. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1817. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1818. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1819. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1820. /** Class used to create color pickers */
  1821. var ColorPicker = /** @class */ (function (_super) {
  1822. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1823. /**
  1824. * Creates a new ColorPicker
  1825. * @param name defines the control name
  1826. */
  1827. function ColorPicker(name) {
  1828. var _this = _super.call(this, name) || this;
  1829. _this.name = name;
  1830. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1831. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1832. _this._pointerStartedOnSquare = false;
  1833. _this._pointerStartedOnWheel = false;
  1834. _this._squareLeft = 0;
  1835. _this._squareTop = 0;
  1836. _this._squareSize = 0;
  1837. _this._h = 360;
  1838. _this._s = 1;
  1839. _this._v = 1;
  1840. _this._lastPointerDownID = -1;
  1841. /**
  1842. * Observable raised when the value changes
  1843. */
  1844. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1845. // Events
  1846. _this._pointerIsDown = false;
  1847. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1848. _this.size = "200px";
  1849. _this.isPointerBlocker = true;
  1850. return _this;
  1851. }
  1852. Object.defineProperty(ColorPicker.prototype, "value", {
  1853. /** Gets or sets the color of the color picker */
  1854. get: function () {
  1855. return this._value;
  1856. },
  1857. set: function (value) {
  1858. if (this._value.equals(value)) {
  1859. return;
  1860. }
  1861. this._value.copyFrom(value);
  1862. this._value.toHSVToRef(this._tmpColor);
  1863. this._h = this._tmpColor.r;
  1864. this._s = Math.max(this._tmpColor.g, 0.00001);
  1865. this._v = Math.max(this._tmpColor.b, 0.00001);
  1866. this._markAsDirty();
  1867. if (this._value.r <= ColorPicker._Epsilon) {
  1868. this._value.r = 0;
  1869. }
  1870. if (this._value.g <= ColorPicker._Epsilon) {
  1871. this._value.g = 0;
  1872. }
  1873. if (this._value.b <= ColorPicker._Epsilon) {
  1874. this._value.b = 0;
  1875. }
  1876. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1877. this._value.r = 1.0;
  1878. }
  1879. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1880. this._value.g = 1.0;
  1881. }
  1882. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1883. this._value.b = 1.0;
  1884. }
  1885. this.onValueChangedObservable.notifyObservers(this._value);
  1886. },
  1887. enumerable: true,
  1888. configurable: true
  1889. });
  1890. Object.defineProperty(ColorPicker.prototype, "width", {
  1891. /**
  1892. * Gets or sets control width
  1893. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1894. */
  1895. get: function () {
  1896. return this._width.toString(this._host);
  1897. },
  1898. set: function (value) {
  1899. if (this._width.toString(this._host) === value) {
  1900. return;
  1901. }
  1902. if (this._width.fromString(value)) {
  1903. this._height.fromString(value);
  1904. this._markAsDirty();
  1905. }
  1906. },
  1907. enumerable: true,
  1908. configurable: true
  1909. });
  1910. Object.defineProperty(ColorPicker.prototype, "height", {
  1911. /**
  1912. * Gets or sets control height
  1913. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1914. */
  1915. get: function () {
  1916. return this._height.toString(this._host);
  1917. },
  1918. /** Gets or sets control height */
  1919. set: function (value) {
  1920. if (this._height.toString(this._host) === value) {
  1921. return;
  1922. }
  1923. if (this._height.fromString(value)) {
  1924. this._width.fromString(value);
  1925. this._markAsDirty();
  1926. }
  1927. },
  1928. enumerable: true,
  1929. configurable: true
  1930. });
  1931. Object.defineProperty(ColorPicker.prototype, "size", {
  1932. /** Gets or sets control size */
  1933. get: function () {
  1934. return this.width;
  1935. },
  1936. set: function (value) {
  1937. this.width = value;
  1938. },
  1939. enumerable: true,
  1940. configurable: true
  1941. });
  1942. ColorPicker.prototype._getTypeName = function () {
  1943. return "ColorPicker";
  1944. };
  1945. /** @hidden */
  1946. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1947. if (parentMeasure.width < parentMeasure.height) {
  1948. this._currentMeasure.height = parentMeasure.width;
  1949. }
  1950. else {
  1951. this._currentMeasure.width = parentMeasure.height;
  1952. }
  1953. };
  1954. ColorPicker.prototype._updateSquareProps = function () {
  1955. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1956. var wheelThickness = radius * .2;
  1957. var innerDiameter = (radius - wheelThickness) * 2;
  1958. var squareSize = innerDiameter / (Math.sqrt(2));
  1959. var offset = radius - squareSize * .5;
  1960. this._squareLeft = this._currentMeasure.left + offset;
  1961. this._squareTop = this._currentMeasure.top + offset;
  1962. this._squareSize = squareSize;
  1963. };
  1964. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1965. var lgh = context.createLinearGradient(left, top, width + left, top);
  1966. lgh.addColorStop(0, '#fff');
  1967. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1968. context.fillStyle = lgh;
  1969. context.fillRect(left, top, width, height);
  1970. var lgv = context.createLinearGradient(left, top, left, height + top);
  1971. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1972. lgv.addColorStop(1, '#000');
  1973. context.fillStyle = lgv;
  1974. context.fillRect(left, top, width, height);
  1975. };
  1976. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1977. context.beginPath();
  1978. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1979. context.lineWidth = 3;
  1980. context.strokeStyle = '#333333';
  1981. context.stroke();
  1982. context.beginPath();
  1983. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1984. context.lineWidth = 3;
  1985. context.strokeStyle = '#ffffff';
  1986. context.stroke();
  1987. };
  1988. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1989. var canvas = document.createElement("canvas");
  1990. canvas.width = radius * 2;
  1991. canvas.height = radius * 2;
  1992. var context = canvas.getContext("2d");
  1993. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1994. var data = image.data;
  1995. var color = this._tmpColor;
  1996. var maxDistSq = radius * radius;
  1997. var innerRadius = radius - thickness;
  1998. var minDistSq = innerRadius * innerRadius;
  1999. for (var x = -radius; x < radius; x++) {
  2000. for (var y = -radius; y < radius; y++) {
  2001. var distSq = x * x + y * y;
  2002. if (distSq > maxDistSq || distSq < minDistSq) {
  2003. continue;
  2004. }
  2005. var dist = Math.sqrt(distSq);
  2006. var ang = Math.atan2(y, x);
  2007. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2008. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2009. data[index] = color.r * 255;
  2010. data[index + 1] = color.g * 255;
  2011. data[index + 2] = color.b * 255;
  2012. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2013. //apply less alpha to bigger color pickers
  2014. var alphaAmount = .2;
  2015. var maxAlpha = .2;
  2016. var minAlpha = .04;
  2017. var lowerRadius = 50;
  2018. var upperRadius = 150;
  2019. if (radius < lowerRadius) {
  2020. alphaAmount = maxAlpha;
  2021. }
  2022. else if (radius > upperRadius) {
  2023. alphaAmount = minAlpha;
  2024. }
  2025. else {
  2026. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2027. }
  2028. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2029. if (alphaRatio < alphaAmount) {
  2030. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2031. }
  2032. else if (alphaRatio > 1 - alphaAmount) {
  2033. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2034. }
  2035. else {
  2036. data[index + 3] = 255;
  2037. }
  2038. }
  2039. }
  2040. context.putImageData(image, 0, 0);
  2041. return canvas;
  2042. };
  2043. /** @hidden */
  2044. ColorPicker.prototype._draw = function (context) {
  2045. context.save();
  2046. this._applyStates(context);
  2047. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2048. var wheelThickness = radius * .2;
  2049. var left = this._currentMeasure.left;
  2050. var top = this._currentMeasure.top;
  2051. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2052. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2053. }
  2054. this._updateSquareProps();
  2055. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2056. context.shadowColor = this.shadowColor;
  2057. context.shadowBlur = this.shadowBlur;
  2058. context.shadowOffsetX = this.shadowOffsetX;
  2059. context.shadowOffsetY = this.shadowOffsetY;
  2060. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2061. }
  2062. context.drawImage(this._colorWheelCanvas, left, top);
  2063. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2064. context.shadowBlur = 0;
  2065. context.shadowOffsetX = 0;
  2066. context.shadowOffsetY = 0;
  2067. }
  2068. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2069. var cx = this._squareLeft + this._squareSize * this._s;
  2070. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2071. this._drawCircle(cx, cy, radius * .04, context);
  2072. var dist = radius - wheelThickness * .5;
  2073. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2074. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2075. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2076. context.restore();
  2077. };
  2078. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2079. if (this._pointerStartedOnWheel) {
  2080. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2081. var centerX = radius + this._currentMeasure.left;
  2082. var centerY = radius + this._currentMeasure.top;
  2083. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2084. }
  2085. else if (this._pointerStartedOnSquare) {
  2086. this._updateSquareProps();
  2087. this._s = (x - this._squareLeft) / this._squareSize;
  2088. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2089. this._s = Math.min(this._s, 1);
  2090. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2091. this._v = Math.min(this._v, 1);
  2092. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2093. }
  2094. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2095. this.value = this._tmpColor;
  2096. };
  2097. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2098. this._updateSquareProps();
  2099. var left = this._squareLeft;
  2100. var top = this._squareTop;
  2101. var size = this._squareSize;
  2102. if (x >= left && x <= left + size &&
  2103. y >= top && y <= top + size) {
  2104. return true;
  2105. }
  2106. return false;
  2107. };
  2108. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2109. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2110. var centerX = radius + this._currentMeasure.left;
  2111. var centerY = radius + this._currentMeasure.top;
  2112. var wheelThickness = radius * .2;
  2113. var innerRadius = radius - wheelThickness;
  2114. var radiusSq = radius * radius;
  2115. var innerRadiusSq = innerRadius * innerRadius;
  2116. var dx = x - centerX;
  2117. var dy = y - centerY;
  2118. var distSq = dx * dx + dy * dy;
  2119. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2120. return true;
  2121. }
  2122. return false;
  2123. };
  2124. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2125. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2126. return false;
  2127. }
  2128. this._pointerIsDown = true;
  2129. this._pointerStartedOnSquare = false;
  2130. this._pointerStartedOnWheel = false;
  2131. // Invert transform
  2132. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2133. var x = this._transformedPosition.x;
  2134. var y = this._transformedPosition.y;
  2135. if (this._isPointOnSquare(x, y)) {
  2136. this._pointerStartedOnSquare = true;
  2137. }
  2138. else if (this._isPointOnWheel(x, y)) {
  2139. this._pointerStartedOnWheel = true;
  2140. }
  2141. this._updateValueFromPointer(x, y);
  2142. this._host._capturingControl[pointerId] = this;
  2143. this._lastPointerDownID = pointerId;
  2144. return true;
  2145. };
  2146. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2147. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2148. if (pointerId != this._lastPointerDownID) {
  2149. return;
  2150. }
  2151. // Invert transform
  2152. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2153. var x = this._transformedPosition.x;
  2154. var y = this._transformedPosition.y;
  2155. if (this._pointerIsDown) {
  2156. this._updateValueFromPointer(x, y);
  2157. }
  2158. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2159. };
  2160. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2161. this._pointerIsDown = false;
  2162. delete this._host._capturingControl[pointerId];
  2163. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2164. };
  2165. /**
  2166. * This function expands the color picker by creating a color picker dialog with manual
  2167. * color value input and the ability to save colors into an array to be used later in
  2168. * subsequent launches of the dialogue.
  2169. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2170. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2171. * @returns picked color as a hex string and the saved colors array as hex strings.
  2172. */
  2173. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2174. return new Promise(function (resolve, reject) {
  2175. // Default options
  2176. options.pickerWidth = options.pickerWidth || "640px";
  2177. options.pickerHeight = options.pickerHeight || "400px";
  2178. options.headerHeight = options.headerHeight || "35px";
  2179. options.lastColor = options.lastColor || "#000000";
  2180. options.swatchLimit = options.swatchLimit || 20;
  2181. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2182. // Window size settings
  2183. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2184. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2185. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2186. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2187. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2188. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2189. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2190. // Button Colors
  2191. var buttonColor = "#c0c0c0";
  2192. var buttonBackgroundColor = "#535353";
  2193. var buttonBackgroundHoverColor = "#414141";
  2194. var buttonBackgroundClickColor = "515151";
  2195. var buttonDisabledColor = "#555555";
  2196. var buttonDisabledBackgroundColor = "#454545";
  2197. var currentSwatchesOutlineColor = "#404040";
  2198. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2199. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2200. var iconColorDark = "#aaaaaa";
  2201. var iconColorLight = "#ffffff";
  2202. var closeIconColor;
  2203. // Button settings
  2204. var buttonFontSize;
  2205. var butEdit;
  2206. var buttonWidth;
  2207. var buttonHeight;
  2208. // Input Text Colors
  2209. var inputFieldLabels = ["R", "G", "B"];
  2210. var inputTextBackgroundColor = "#454545";
  2211. var inputTextColor = "#f0f0f0";
  2212. // This is the current color as set by either the picker or by entering a value
  2213. var currentColor;
  2214. // This int is used for naming swatches and serves as the index for calling them from the list
  2215. var swatchNumber;
  2216. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2217. var swatchDrawer;
  2218. var editSwatchMode = false;
  2219. // Color InputText fields that will be updated upon value change
  2220. var picker;
  2221. var rValInt;
  2222. var gValInt;
  2223. var bValInt;
  2224. var rValDec;
  2225. var gValDec;
  2226. var bValDec;
  2227. var hexVal;
  2228. var newSwatch;
  2229. var lastVal;
  2230. var activeField;
  2231. /**
  2232. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2233. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2234. * are will receive no update. This is to prevent the input from the user being overwritten.
  2235. */
  2236. function updateValues(value, inputField) {
  2237. activeField = inputField;
  2238. var pickedColor = value.toHexString();
  2239. newSwatch.background = pickedColor;
  2240. if (rValInt.name != activeField) {
  2241. rValInt.text = Math.floor(value.r * 255).toString();
  2242. }
  2243. if (gValInt.name != activeField) {
  2244. gValInt.text = Math.floor(value.g * 255).toString();
  2245. }
  2246. if (bValInt.name != activeField) {
  2247. bValInt.text = Math.floor(value.b * 255).toString();
  2248. }
  2249. if (rValDec.name != activeField) {
  2250. rValDec.text = value.r.toString();
  2251. }
  2252. if (gValDec.name != activeField) {
  2253. gValDec.text = value.g.toString();
  2254. }
  2255. if (bValDec.name != activeField) {
  2256. bValDec.text = value.b.toString();
  2257. }
  2258. if (hexVal.name != activeField) {
  2259. var minusPound = pickedColor.split("#");
  2260. hexVal.text = minusPound[1];
  2261. }
  2262. if (picker.name != activeField) {
  2263. picker.value = value;
  2264. }
  2265. }
  2266. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2267. function updateInt(field, channel) {
  2268. var newValue = field.text;
  2269. var checkVal = /[^0-9]/g.test(newValue);
  2270. if (checkVal) {
  2271. field.text = lastVal;
  2272. return;
  2273. }
  2274. else {
  2275. if (newValue != "") {
  2276. if (Math.floor(parseInt(newValue)) < 0) {
  2277. newValue = "0";
  2278. }
  2279. else if (Math.floor(parseInt(newValue)) > 255) {
  2280. newValue = "255";
  2281. }
  2282. else if (isNaN(parseInt(newValue))) {
  2283. newValue = "0";
  2284. }
  2285. }
  2286. if (activeField == field.name) {
  2287. lastVal = newValue;
  2288. }
  2289. }
  2290. if (newValue != "") {
  2291. newValue = parseInt(newValue).toString();
  2292. field.text = newValue;
  2293. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2294. if (activeField == field.name) {
  2295. if (channel == "r") {
  2296. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2297. }
  2298. else if (channel == "g") {
  2299. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2300. }
  2301. else {
  2302. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2303. }
  2304. }
  2305. }
  2306. }
  2307. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2308. function updateFloat(field, channel) {
  2309. var newValue = field.text;
  2310. var checkVal = /[^0-9\.]/g.test(newValue);
  2311. if (checkVal) {
  2312. field.text = lastVal;
  2313. return;
  2314. }
  2315. else {
  2316. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2317. if (parseFloat(newValue) < 0.0) {
  2318. newValue = "0.0";
  2319. }
  2320. else if (parseFloat(newValue) > 1.0) {
  2321. newValue = "1.0";
  2322. }
  2323. else if (isNaN(parseFloat(newValue))) {
  2324. newValue = "0.0";
  2325. }
  2326. }
  2327. if (activeField == field.name) {
  2328. lastVal = newValue;
  2329. }
  2330. }
  2331. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2332. newValue = parseFloat(newValue).toString();
  2333. field.text = newValue;
  2334. }
  2335. else {
  2336. newValue = "0.0";
  2337. }
  2338. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2339. if (activeField == field.name) {
  2340. if (channel == "r") {
  2341. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2342. }
  2343. else if (channel == "g") {
  2344. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2345. }
  2346. else {
  2347. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2348. }
  2349. }
  2350. }
  2351. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2352. function deleteSwatch(index) {
  2353. if (options.savedColors) {
  2354. options.savedColors.splice(index, 1);
  2355. }
  2356. if (options.savedColors && options.savedColors.length == 0) {
  2357. setEditButtonVisibility(false);
  2358. editSwatchMode = false;
  2359. }
  2360. }
  2361. // Creates and styles an individual swatch when updateSwatches is called.
  2362. function createSwatch() {
  2363. if (options.savedColors && options.savedColors[swatchNumber]) {
  2364. if (editSwatchMode) {
  2365. var icon = "b";
  2366. }
  2367. else {
  2368. var icon = "";
  2369. }
  2370. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2371. swatch.fontFamily = "BabylonJSglyphs";
  2372. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2373. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2374. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2375. if (swatchLuminence > luminanceLimit) {
  2376. swatch.color = iconColorDark;
  2377. }
  2378. else {
  2379. swatch.color = iconColorLight;
  2380. }
  2381. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2382. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2383. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2384. swatch.background = options.savedColors[swatchNumber];
  2385. swatch.thickness = 2;
  2386. var metadata_1 = swatchNumber;
  2387. swatch.pointerDownAnimation = function () {
  2388. swatch.thickness = 4;
  2389. };
  2390. swatch.pointerUpAnimation = function () {
  2391. swatch.thickness = 3;
  2392. };
  2393. swatch.pointerEnterAnimation = function () {
  2394. swatch.thickness = 3;
  2395. };
  2396. swatch.pointerOutAnimation = function () {
  2397. swatch.thickness = 2;
  2398. };
  2399. swatch.onPointerClickObservable.add(function () {
  2400. if (!editSwatchMode) {
  2401. if (options.savedColors) {
  2402. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2403. }
  2404. }
  2405. else {
  2406. deleteSwatch(metadata_1);
  2407. updateSwatches("", butSave);
  2408. }
  2409. });
  2410. return swatch;
  2411. }
  2412. else {
  2413. return null;
  2414. }
  2415. }
  2416. // Mode switch to render button text and close symbols on swatch controls
  2417. function editSwatches(mode) {
  2418. if (mode !== undefined) {
  2419. editSwatchMode = mode;
  2420. }
  2421. if (editSwatchMode) {
  2422. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2423. var thisButton = swatchDrawer.children[i];
  2424. thisButton.textBlock.text = "b";
  2425. }
  2426. if (butEdit !== undefined) {
  2427. butEdit.textBlock.text = "Done";
  2428. }
  2429. }
  2430. else {
  2431. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2432. var thisButton = swatchDrawer.children[i];
  2433. thisButton.textBlock.text = "";
  2434. }
  2435. if (butEdit !== undefined) {
  2436. butEdit.textBlock.text = "Edit";
  2437. }
  2438. }
  2439. }
  2440. /**
  2441. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2442. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2443. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2444. * saved colors there are and how many can be stored per row.
  2445. */
  2446. function updateSwatches(color, button) {
  2447. if (options.savedColors) {
  2448. if (color != "") {
  2449. options.savedColors.push(color);
  2450. }
  2451. swatchNumber = 0;
  2452. swatchDrawer.clearControls();
  2453. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2454. if (rowCount == 0) {
  2455. var gutterCount = 0;
  2456. }
  2457. else {
  2458. var gutterCount = rowCount + 1;
  2459. }
  2460. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2461. var currentRows = swatchDrawer.rowCount;
  2462. for (var i = 0; i < currentRows; i++) {
  2463. swatchDrawer.removeRowDefinition(0);
  2464. }
  2465. for (var i = 0; i < rowCount + gutterCount; i++) {
  2466. if (i % 2) {
  2467. swatchDrawer.addRowDefinition(swatchSize, true);
  2468. }
  2469. else {
  2470. swatchDrawer.addRowDefinition(gutterSize, true);
  2471. }
  2472. }
  2473. }
  2474. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2475. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2476. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2477. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2478. var totalButtonsThisRow = options.numSwatchesPerLine;
  2479. }
  2480. else {
  2481. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2482. }
  2483. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2484. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2485. if (x > options.numSwatchesPerLine) {
  2486. continue;
  2487. }
  2488. var swatch = createSwatch();
  2489. if (swatch != null) {
  2490. swatchDrawer.addControl(swatch, y, w);
  2491. w += 2;
  2492. swatchNumber++;
  2493. }
  2494. else {
  2495. continue;
  2496. }
  2497. }
  2498. }
  2499. if (options.savedColors.length >= options.swatchLimit) {
  2500. disableButton(button, true);
  2501. }
  2502. else {
  2503. disableButton(button, false);
  2504. }
  2505. }
  2506. }
  2507. // Shows or hides edit swatches button depending on if there are saved swatches
  2508. function setEditButtonVisibility(enableButton) {
  2509. if (enableButton) {
  2510. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2511. butEdit.width = buttonWidth;
  2512. butEdit.height = buttonHeight;
  2513. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2514. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2515. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2516. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2517. butEdit.thickness = 2;
  2518. butEdit.color = buttonColor;
  2519. butEdit.fontSize = buttonFontSize;
  2520. butEdit.background = buttonBackgroundColor;
  2521. butEdit.onPointerEnterObservable.add(function () {
  2522. butEdit.background = buttonBackgroundHoverColor;
  2523. });
  2524. butEdit.onPointerOutObservable.add(function () {
  2525. butEdit.background = buttonBackgroundColor;
  2526. });
  2527. butEdit.pointerDownAnimation = function () {
  2528. butEdit.background = buttonBackgroundClickColor;
  2529. };
  2530. butEdit.pointerUpAnimation = function () {
  2531. butEdit.background = buttonBackgroundHoverColor;
  2532. };
  2533. butEdit.onPointerClickObservable.add(function () {
  2534. if (editSwatchMode) {
  2535. editSwatchMode = false;
  2536. }
  2537. else {
  2538. editSwatchMode = true;
  2539. }
  2540. editSwatches();
  2541. });
  2542. pickerGrid.addControl(butEdit, 1, 0);
  2543. }
  2544. else {
  2545. pickerGrid.removeControl(butEdit);
  2546. }
  2547. }
  2548. // Called when the user hits the limit of saved colors in the drawer.
  2549. function disableButton(button, disabled) {
  2550. if (disabled) {
  2551. button.color = buttonDisabledColor;
  2552. button.background = buttonDisabledBackgroundColor;
  2553. }
  2554. else {
  2555. button.color = buttonColor;
  2556. button.background = buttonBackgroundColor;
  2557. }
  2558. }
  2559. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2560. function closePicker(color) {
  2561. if (options.savedColors && options.savedColors.length > 0) {
  2562. resolve({
  2563. savedColors: options.savedColors,
  2564. pickedColor: color
  2565. });
  2566. }
  2567. else {
  2568. resolve({
  2569. pickedColor: color
  2570. });
  2571. }
  2572. advancedTexture.removeControl(dialogContainer);
  2573. }
  2574. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2575. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2576. dialogContainer.name = "Dialog Container";
  2577. dialogContainer.width = options.pickerWidth;
  2578. if (options.savedColors) {
  2579. dialogContainer.height = containerSize;
  2580. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2581. dialogContainer.addRowDefinition(topRow, false);
  2582. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2583. }
  2584. else {
  2585. dialogContainer.height = options.pickerHeight;
  2586. dialogContainer.addRowDefinition(1.0, false);
  2587. }
  2588. advancedTexture.addControl(dialogContainer);
  2589. // Swatch drawer which contains all saved color buttons
  2590. if (options.savedColors) {
  2591. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2592. swatchDrawer.name = "Swatch Drawer";
  2593. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2594. swatchDrawer.background = buttonBackgroundColor;
  2595. swatchDrawer.width = options.pickerWidth;
  2596. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2597. if (initialRows == 0) {
  2598. var gutterCount = 0;
  2599. }
  2600. else {
  2601. var gutterCount = initialRows + 1;
  2602. }
  2603. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2604. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2605. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2606. if (i % 2 != 0) {
  2607. swatchDrawer.addRowDefinition(swatchSize, true);
  2608. }
  2609. else {
  2610. swatchDrawer.addRowDefinition(gutterSize, true);
  2611. }
  2612. }
  2613. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2614. if (i % 2 != 0) {
  2615. swatchDrawer.addColumnDefinition(swatchSize, true);
  2616. }
  2617. else {
  2618. swatchDrawer.addColumnDefinition(gutterSize, true);
  2619. }
  2620. }
  2621. dialogContainer.addControl(swatchDrawer, 1, 0);
  2622. }
  2623. // Picker container
  2624. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2625. pickerPanel.name = "Picker Panel";
  2626. pickerPanel.height = options.pickerHeight;
  2627. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2628. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2629. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2630. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2631. dialogContainer.addControl(pickerPanel, 0, 0);
  2632. // Picker container header
  2633. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2634. header.name = "Dialogue Header Bar";
  2635. header.background = "#cccccc";
  2636. header.thickness = 0;
  2637. pickerPanel.addControl(header, 0, 0);
  2638. // Header close button
  2639. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2640. closeButton.fontFamily = "BabylonJSglyphs";
  2641. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2642. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2643. closeButton.color = closeIconColor.toHexString();
  2644. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2645. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2646. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2647. closeButton.height = closeButton.width = options.headerHeight;
  2648. closeButton.background = header.background;
  2649. closeButton.thickness = 0;
  2650. closeButton.pointerDownAnimation = function () {
  2651. };
  2652. closeButton.pointerUpAnimation = function () {
  2653. closeButton.background = header.background;
  2654. };
  2655. closeButton.pointerEnterAnimation = function () {
  2656. closeButton.color = header.background;
  2657. closeButton.background = "red";
  2658. };
  2659. closeButton.pointerOutAnimation = function () {
  2660. closeButton.color = closeIconColor.toHexString();
  2661. closeButton.background = header.background;
  2662. };
  2663. closeButton.onPointerClickObservable.add(function () {
  2664. closePicker(currentSwatch.background);
  2665. });
  2666. pickerPanel.addControl(closeButton, 0, 0);
  2667. // Dialog container body
  2668. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2669. dialogBody.name = "Dialogue Body";
  2670. dialogBody.background = buttonBackgroundColor;
  2671. var dialogBodyCols = [0.4375, 0.5625];
  2672. dialogBody.addRowDefinition(1.0, false);
  2673. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2674. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2675. pickerPanel.addControl(dialogBody, 1, 0);
  2676. // Picker grid
  2677. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2678. pickerGrid.name = "Picker Grid";
  2679. pickerGrid.addRowDefinition(0.85, false);
  2680. pickerGrid.addRowDefinition(0.15, false);
  2681. dialogBody.addControl(pickerGrid, 0, 0);
  2682. // Picker control
  2683. picker = new ColorPicker();
  2684. picker.name = "GUI Color Picker";
  2685. if (options.pickerHeight < options.pickerWidth) {
  2686. picker.width = 0.89;
  2687. }
  2688. else {
  2689. picker.height = 0.89;
  2690. }
  2691. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2692. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2693. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2694. picker.onPointerDownObservable.add(function () {
  2695. activeField = picker.name;
  2696. lastVal = "";
  2697. editSwatches(false);
  2698. });
  2699. picker.onValueChangedObservable.add(function (value) {
  2700. if (activeField == picker.name) {
  2701. updateValues(value, picker.name);
  2702. }
  2703. });
  2704. pickerGrid.addControl(picker, 0, 0);
  2705. // Picker body right quarant
  2706. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2707. pickerBodyRight.name = "Dialogue Right Half";
  2708. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2709. var pickerBodyRightRows = [0.514, 0.486];
  2710. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2711. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2712. dialogBody.addControl(pickerBodyRight, 1, 1);
  2713. // Picker container swatches and buttons
  2714. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2715. pickerSwatchesButtons.name = "Swatches and Buttons";
  2716. var pickerButtonsCol = [0.417, 0.583];
  2717. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2718. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2719. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2720. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2721. // Picker Swatches quadrant
  2722. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2723. pickerSwatches.name = "New and Current Swatches";
  2724. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2725. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2726. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2727. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2728. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2729. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2730. // Active swatches
  2731. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2732. activeSwatches.name = "Active Swatches";
  2733. activeSwatches.width = 0.67;
  2734. activeSwatches.addRowDefinition(0.5, false);
  2735. activeSwatches.addRowDefinition(0.5, false);
  2736. pickerSwatches.addControl(activeSwatches, 2, 0);
  2737. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2738. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2739. if (options.pickerWidth > options.pickerHeight) {
  2740. var labelTextSize = labelHeight;
  2741. }
  2742. else {
  2743. var labelTextSize = labelWidth;
  2744. }
  2745. // New color swatch and previous color button
  2746. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2747. newText.text = "new";
  2748. newText.name = "New Color Label";
  2749. newText.color = buttonColor;
  2750. newText.fontSize = labelTextSize;
  2751. pickerSwatches.addControl(newText, 1, 0);
  2752. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2753. newSwatch.name = "New Color Swatch";
  2754. newSwatch.background = options.lastColor;
  2755. newSwatch.thickness = 0;
  2756. activeSwatches.addControl(newSwatch, 0, 0);
  2757. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2758. currentSwatch.background = options.lastColor;
  2759. currentSwatch.thickness = 0;
  2760. currentSwatch.onPointerClickObservable.add(function () {
  2761. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2762. updateValues(revertColor, currentSwatch.name);
  2763. editSwatches(false);
  2764. });
  2765. currentSwatch.pointerDownAnimation = function () { };
  2766. currentSwatch.pointerUpAnimation = function () { };
  2767. currentSwatch.pointerEnterAnimation = function () { };
  2768. currentSwatch.pointerOutAnimation = function () { };
  2769. activeSwatches.addControl(currentSwatch, 1, 0);
  2770. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2771. swatchOutline.name = "Swatch Outline";
  2772. swatchOutline.width = 0.67;
  2773. swatchOutline.thickness = 2;
  2774. swatchOutline.color = currentSwatchesOutlineColor;
  2775. swatchOutline.isHitTestVisible = false;
  2776. pickerSwatches.addControl(swatchOutline, 2, 0);
  2777. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2778. currentText.name = "Current Color Label";
  2779. currentText.text = "current";
  2780. currentText.color = buttonColor;
  2781. currentText.fontSize = labelTextSize;
  2782. pickerSwatches.addControl(currentText, 3, 0);
  2783. // Buttons grid
  2784. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2785. buttonGrid.name = "Button Grid";
  2786. buttonGrid.height = 0.8;
  2787. var buttonGridRows = 1 / 3;
  2788. buttonGrid.addRowDefinition(buttonGridRows, false);
  2789. buttonGrid.addRowDefinition(buttonGridRows, false);
  2790. buttonGrid.addRowDefinition(buttonGridRows, false);
  2791. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2792. // Determine pixel width and height for all buttons from overall panel dimensions
  2793. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2794. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2795. // Determine button type size
  2796. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2797. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2798. }
  2799. else {
  2800. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2801. }
  2802. // Panel Buttons
  2803. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2804. butOK.width = buttonWidth;
  2805. butOK.height = buttonHeight;
  2806. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2807. butOK.thickness = 2;
  2808. butOK.color = buttonColor;
  2809. butOK.fontSize = buttonFontSize;
  2810. butOK.background = buttonBackgroundColor;
  2811. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2812. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2813. butOK.pointerDownAnimation = function () {
  2814. butOK.background = buttonBackgroundClickColor;
  2815. };
  2816. butOK.pointerUpAnimation = function () {
  2817. butOK.background = buttonBackgroundHoverColor;
  2818. };
  2819. butOK.onPointerClickObservable.add(function () {
  2820. editSwatches(false);
  2821. closePicker(newSwatch.background);
  2822. });
  2823. buttonGrid.addControl(butOK, 0, 0);
  2824. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2825. butCancel.width = buttonWidth;
  2826. butCancel.height = buttonHeight;
  2827. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2828. butCancel.thickness = 2;
  2829. butCancel.color = buttonColor;
  2830. butCancel.fontSize = buttonFontSize;
  2831. butCancel.background = buttonBackgroundColor;
  2832. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2833. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2834. butCancel.pointerDownAnimation = function () {
  2835. butCancel.background = buttonBackgroundClickColor;
  2836. };
  2837. butCancel.pointerUpAnimation = function () {
  2838. butCancel.background = buttonBackgroundHoverColor;
  2839. };
  2840. butCancel.onPointerClickObservable.add(function () {
  2841. editSwatches(false);
  2842. closePicker(currentSwatch.background);
  2843. });
  2844. buttonGrid.addControl(butCancel, 1, 0);
  2845. if (options.savedColors) {
  2846. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2847. butSave.width = buttonWidth;
  2848. butSave.height = buttonHeight;
  2849. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2850. butSave.thickness = 2;
  2851. butSave.fontSize = buttonFontSize;
  2852. if (options.savedColors.length < options.swatchLimit) {
  2853. butSave.color = buttonColor;
  2854. butSave.background = buttonBackgroundColor;
  2855. }
  2856. else {
  2857. disableButton(butSave, true);
  2858. }
  2859. butSave.onPointerEnterObservable.add(function () {
  2860. if (options.savedColors) {
  2861. if (options.savedColors.length < options.swatchLimit) {
  2862. butSave.background = buttonBackgroundHoverColor;
  2863. }
  2864. }
  2865. });
  2866. butSave.onPointerOutObservable.add(function () {
  2867. if (options.savedColors) {
  2868. if (options.savedColors.length < options.swatchLimit) {
  2869. butSave.background = buttonBackgroundColor;
  2870. }
  2871. }
  2872. });
  2873. butSave.pointerDownAnimation = function () {
  2874. if (options.savedColors) {
  2875. if (options.savedColors.length < options.swatchLimit) {
  2876. butSave.background = buttonBackgroundClickColor;
  2877. }
  2878. }
  2879. };
  2880. butSave.pointerUpAnimation = function () {
  2881. if (options.savedColors) {
  2882. if (options.savedColors.length < options.swatchLimit) {
  2883. butSave.background = buttonBackgroundHoverColor;
  2884. }
  2885. }
  2886. };
  2887. butSave.onPointerClickObservable.add(function () {
  2888. if (options.savedColors) {
  2889. if (options.savedColors.length == 0) {
  2890. setEditButtonVisibility(true);
  2891. }
  2892. if (options.savedColors.length < options.swatchLimit) {
  2893. updateSwatches(newSwatch.background, butSave);
  2894. }
  2895. editSwatches(false);
  2896. }
  2897. });
  2898. if (options.savedColors.length > 0) {
  2899. setEditButtonVisibility(true);
  2900. }
  2901. buttonGrid.addControl(butSave, 2, 0);
  2902. }
  2903. // Picker color values input
  2904. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2905. pickerColorValues.name = "Dialog Lower Right";
  2906. pickerColorValues.addRowDefinition(0.02, false);
  2907. pickerColorValues.addRowDefinition(0.63, false);
  2908. pickerColorValues.addRowDefinition(0.21, false);
  2909. pickerColorValues.addRowDefinition(0.14, false);
  2910. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2911. // RGB values text boxes
  2912. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2913. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2914. rgbValuesQuadrant.name = "RGB Values";
  2915. rgbValuesQuadrant.width = 0.82;
  2916. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2917. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2918. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2919. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2920. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2921. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2922. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2923. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2924. for (var i = 0; i < inputFieldLabels.length; i++) {
  2925. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2926. labelText.text = inputFieldLabels[i];
  2927. labelText.color = buttonColor;
  2928. labelText.fontSize = buttonFontSize;
  2929. rgbValuesQuadrant.addControl(labelText, i, 0);
  2930. }
  2931. // Input fields for RGB values
  2932. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2933. rValInt.width = 0.83;
  2934. rValInt.height = 0.72;
  2935. rValInt.name = "rIntField";
  2936. rValInt.fontSize = buttonFontSize;
  2937. rValInt.text = (currentColor.r * 255).toString();
  2938. rValInt.color = inputTextColor;
  2939. rValInt.background = inputTextBackgroundColor;
  2940. rValInt.onFocusObservable.add(function () {
  2941. activeField = rValInt.name;
  2942. lastVal = rValInt.text;
  2943. editSwatches(false);
  2944. });
  2945. rValInt.onBlurObservable.add(function () {
  2946. if (rValInt.text == "") {
  2947. rValInt.text = "0";
  2948. }
  2949. updateInt(rValInt, "r");
  2950. if (activeField == rValInt.name) {
  2951. activeField = "";
  2952. }
  2953. });
  2954. rValInt.onTextChangedObservable.add(function () {
  2955. if (activeField == rValInt.name) {
  2956. updateInt(rValInt, "r");
  2957. }
  2958. });
  2959. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2960. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2961. gValInt.width = 0.83;
  2962. gValInt.height = 0.72;
  2963. gValInt.name = "gIntField";
  2964. gValInt.fontSize = buttonFontSize;
  2965. gValInt.text = (currentColor.g * 255).toString();
  2966. gValInt.color = inputTextColor;
  2967. gValInt.background = inputTextBackgroundColor;
  2968. gValInt.onFocusObservable.add(function () {
  2969. activeField = gValInt.name;
  2970. lastVal = gValInt.text;
  2971. editSwatches(false);
  2972. });
  2973. gValInt.onBlurObservable.add(function () {
  2974. if (gValInt.text == "") {
  2975. gValInt.text = "0";
  2976. }
  2977. updateInt(gValInt, "g");
  2978. if (activeField == gValInt.name) {
  2979. activeField = "";
  2980. }
  2981. });
  2982. gValInt.onTextChangedObservable.add(function () {
  2983. if (activeField == gValInt.name) {
  2984. updateInt(gValInt, "g");
  2985. }
  2986. });
  2987. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2988. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2989. bValInt.width = 0.83;
  2990. bValInt.height = 0.72;
  2991. bValInt.name = "bIntField";
  2992. bValInt.fontSize = buttonFontSize;
  2993. bValInt.text = (currentColor.b * 255).toString();
  2994. bValInt.color = inputTextColor;
  2995. bValInt.background = inputTextBackgroundColor;
  2996. bValInt.onFocusObservable.add(function () {
  2997. activeField = bValInt.name;
  2998. lastVal = bValInt.text;
  2999. editSwatches(false);
  3000. });
  3001. bValInt.onBlurObservable.add(function () {
  3002. if (bValInt.text == "") {
  3003. bValInt.text = "0";
  3004. }
  3005. updateInt(bValInt, "b");
  3006. if (activeField == bValInt.name) {
  3007. activeField = "";
  3008. }
  3009. });
  3010. bValInt.onTextChangedObservable.add(function () {
  3011. if (activeField == bValInt.name) {
  3012. updateInt(bValInt, "b");
  3013. }
  3014. });
  3015. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3016. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3017. rValDec.width = 0.95;
  3018. rValDec.height = 0.72;
  3019. rValDec.name = "rDecField";
  3020. rValDec.fontSize = buttonFontSize;
  3021. rValDec.text = currentColor.r.toString();
  3022. rValDec.color = inputTextColor;
  3023. rValDec.background = inputTextBackgroundColor;
  3024. rValDec.onFocusObservable.add(function () {
  3025. activeField = rValDec.name;
  3026. lastVal = rValDec.text;
  3027. editSwatches(false);
  3028. });
  3029. rValDec.onBlurObservable.add(function () {
  3030. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3031. rValDec.text = "0";
  3032. updateFloat(rValDec, "r");
  3033. }
  3034. if (activeField == rValDec.name) {
  3035. activeField = "";
  3036. }
  3037. });
  3038. rValDec.onTextChangedObservable.add(function () {
  3039. if (activeField == rValDec.name) {
  3040. updateFloat(rValDec, "r");
  3041. }
  3042. });
  3043. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3044. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3045. gValDec.width = 0.95;
  3046. gValDec.height = 0.72;
  3047. gValDec.name = "gDecField";
  3048. gValDec.fontSize = buttonFontSize;
  3049. gValDec.text = currentColor.g.toString();
  3050. gValDec.color = inputTextColor;
  3051. gValDec.background = inputTextBackgroundColor;
  3052. gValDec.onFocusObservable.add(function () {
  3053. activeField = gValDec.name;
  3054. lastVal = gValDec.text;
  3055. editSwatches(false);
  3056. });
  3057. gValDec.onBlurObservable.add(function () {
  3058. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3059. gValDec.text = "0";
  3060. updateFloat(gValDec, "g");
  3061. }
  3062. if (activeField == gValDec.name) {
  3063. activeField = "";
  3064. }
  3065. });
  3066. gValDec.onTextChangedObservable.add(function () {
  3067. if (activeField == gValDec.name) {
  3068. updateFloat(gValDec, "g");
  3069. }
  3070. });
  3071. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3072. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3073. bValDec.width = 0.95;
  3074. bValDec.height = 0.72;
  3075. bValDec.name = "bDecField";
  3076. bValDec.fontSize = buttonFontSize;
  3077. bValDec.text = currentColor.b.toString();
  3078. bValDec.color = inputTextColor;
  3079. bValDec.background = inputTextBackgroundColor;
  3080. bValDec.onFocusObservable.add(function () {
  3081. activeField = bValDec.name;
  3082. lastVal = bValDec.text;
  3083. editSwatches(false);
  3084. });
  3085. bValDec.onBlurObservable.add(function () {
  3086. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3087. bValDec.text = "0";
  3088. updateFloat(bValDec, "b");
  3089. }
  3090. if (activeField == bValDec.name) {
  3091. activeField = "";
  3092. }
  3093. });
  3094. bValDec.onTextChangedObservable.add(function () {
  3095. if (activeField == bValDec.name) {
  3096. updateFloat(bValDec, "b");
  3097. }
  3098. });
  3099. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3100. // Hex value input
  3101. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3102. hexValueQuadrant.name = "Hex Value";
  3103. hexValueQuadrant.width = 0.82;
  3104. hexValueQuadrant.addRowDefinition(1.0, false);
  3105. hexValueQuadrant.addColumnDefinition(0.1, false);
  3106. hexValueQuadrant.addColumnDefinition(0.9, false);
  3107. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3108. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3109. labelText.text = "#";
  3110. labelText.color = buttonColor;
  3111. labelText.fontSize = buttonFontSize;
  3112. hexValueQuadrant.addControl(labelText, 0, 0);
  3113. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3114. hexVal.width = 0.96;
  3115. hexVal.height = 0.72;
  3116. hexVal.name = "hexField";
  3117. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3118. hexVal.fontSize = buttonFontSize;
  3119. var minusPound = options.lastColor.split("#");
  3120. hexVal.text = minusPound[1];
  3121. hexVal.color = inputTextColor;
  3122. hexVal.background = inputTextBackgroundColor;
  3123. hexVal.onFocusObservable.add(function () {
  3124. activeField = hexVal.name;
  3125. lastVal = hexVal.text;
  3126. editSwatches(false);
  3127. });
  3128. hexVal.onBlurObservable.add(function () {
  3129. if (hexVal.text.length == 3) {
  3130. var val = hexVal.text.split("");
  3131. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3132. }
  3133. if (hexVal.text == "") {
  3134. hexVal.text = "000000";
  3135. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3136. }
  3137. if (activeField == hexVal.name) {
  3138. activeField = "";
  3139. }
  3140. });
  3141. hexVal.onTextChangedObservable.add(function () {
  3142. var newHexValue = hexVal.text;
  3143. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3144. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3145. hexVal.text = lastVal;
  3146. }
  3147. else {
  3148. if (hexVal.text.length < 6) {
  3149. var leadingZero = 6 - hexVal.text.length;
  3150. for (var i = 0; i < leadingZero; i++) {
  3151. newHexValue = "0" + newHexValue;
  3152. }
  3153. }
  3154. if (hexVal.text.length == 3) {
  3155. var val = hexVal.text.split("");
  3156. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3157. }
  3158. newHexValue = "#" + newHexValue;
  3159. if (activeField == hexVal.name) {
  3160. lastVal = hexVal.text;
  3161. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3162. }
  3163. }
  3164. });
  3165. hexValueQuadrant.addControl(hexVal, 0, 1);
  3166. if (options.savedColors && options.savedColors.length > 0) {
  3167. updateSwatches("", butSave);
  3168. }
  3169. });
  3170. };
  3171. ColorPicker._Epsilon = 0.000001;
  3172. return ColorPicker;
  3173. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3174. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3175. /***/ }),
  3176. /***/ "./2D/controls/container.ts":
  3177. /*!**********************************!*\
  3178. !*** ./2D/controls/container.ts ***!
  3179. \**********************************/
  3180. /*! exports provided: Container */
  3181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3182. "use strict";
  3183. __webpack_require__.r(__webpack_exports__);
  3184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3185. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3186. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math.vector");
  3187. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3188. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3189. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3190. /**
  3191. * Root class for 2D containers
  3192. * @see http://doc.babylonjs.com/how_to/gui#containers
  3193. */
  3194. var Container = /** @class */ (function (_super) {
  3195. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3196. /**
  3197. * Creates a new Container
  3198. * @param name defines the name of the container
  3199. */
  3200. function Container(name) {
  3201. var _this = _super.call(this, name) || this;
  3202. _this.name = name;
  3203. /** @hidden */
  3204. _this._children = new Array();
  3205. /** @hidden */
  3206. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3207. /** @hidden */
  3208. _this._background = "";
  3209. /** @hidden */
  3210. _this._adaptWidthToChildren = false;
  3211. /** @hidden */
  3212. _this._adaptHeightToChildren = false;
  3213. /**
  3214. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3215. */
  3216. _this.logLayoutCycleErrors = false;
  3217. /**
  3218. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3219. */
  3220. _this.maxLayoutCycle = 3;
  3221. return _this;
  3222. }
  3223. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3224. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3225. get: function () {
  3226. return this._adaptHeightToChildren;
  3227. },
  3228. set: function (value) {
  3229. if (this._adaptHeightToChildren === value) {
  3230. return;
  3231. }
  3232. this._adaptHeightToChildren = value;
  3233. if (value) {
  3234. this.height = "100%";
  3235. }
  3236. this._markAsDirty();
  3237. },
  3238. enumerable: true,
  3239. configurable: true
  3240. });
  3241. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3242. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3243. get: function () {
  3244. return this._adaptWidthToChildren;
  3245. },
  3246. set: function (value) {
  3247. if (this._adaptWidthToChildren === value) {
  3248. return;
  3249. }
  3250. this._adaptWidthToChildren = value;
  3251. if (value) {
  3252. this.width = "100%";
  3253. }
  3254. this._markAsDirty();
  3255. },
  3256. enumerable: true,
  3257. configurable: true
  3258. });
  3259. Object.defineProperty(Container.prototype, "background", {
  3260. /** Gets or sets background color */
  3261. get: function () {
  3262. return this._background;
  3263. },
  3264. set: function (value) {
  3265. if (this._background === value) {
  3266. return;
  3267. }
  3268. this._background = value;
  3269. this._markAsDirty();
  3270. },
  3271. enumerable: true,
  3272. configurable: true
  3273. });
  3274. Object.defineProperty(Container.prototype, "children", {
  3275. /** Gets the list of children */
  3276. get: function () {
  3277. return this._children;
  3278. },
  3279. enumerable: true,
  3280. configurable: true
  3281. });
  3282. Container.prototype._getTypeName = function () {
  3283. return "Container";
  3284. };
  3285. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3286. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3287. var child = _a[_i];
  3288. child._markMatrixAsDirty();
  3289. }
  3290. };
  3291. /**
  3292. * Gets a child using its name
  3293. * @param name defines the child name to look for
  3294. * @returns the child control if found
  3295. */
  3296. Container.prototype.getChildByName = function (name) {
  3297. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3298. var child = _a[_i];
  3299. if (child.name === name) {
  3300. return child;
  3301. }
  3302. }
  3303. return null;
  3304. };
  3305. /**
  3306. * Gets a child using its type and its name
  3307. * @param name defines the child name to look for
  3308. * @param type defines the child type to look for
  3309. * @returns the child control if found
  3310. */
  3311. Container.prototype.getChildByType = function (name, type) {
  3312. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3313. var child = _a[_i];
  3314. if (child.typeName === type) {
  3315. return child;
  3316. }
  3317. }
  3318. return null;
  3319. };
  3320. /**
  3321. * Search for a specific control in children
  3322. * @param control defines the control to look for
  3323. * @returns true if the control is in child list
  3324. */
  3325. Container.prototype.containsControl = function (control) {
  3326. return this.children.indexOf(control) !== -1;
  3327. };
  3328. /**
  3329. * Adds a new control to the current container
  3330. * @param control defines the control to add
  3331. * @returns the current container
  3332. */
  3333. Container.prototype.addControl = function (control) {
  3334. if (!control) {
  3335. return this;
  3336. }
  3337. var index = this._children.indexOf(control);
  3338. if (index !== -1) {
  3339. return this;
  3340. }
  3341. control._link(this._host);
  3342. control._markAllAsDirty();
  3343. this._reOrderControl(control);
  3344. this._markAsDirty();
  3345. return this;
  3346. };
  3347. /**
  3348. * Removes all controls from the current container
  3349. * @returns the current container
  3350. */
  3351. Container.prototype.clearControls = function () {
  3352. var children = this.children.slice();
  3353. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3354. var child = children_1[_i];
  3355. this.removeControl(child);
  3356. }
  3357. return this;
  3358. };
  3359. /**
  3360. * Removes a control from the current container
  3361. * @param control defines the control to remove
  3362. * @returns the current container
  3363. */
  3364. Container.prototype.removeControl = function (control) {
  3365. var index = this._children.indexOf(control);
  3366. if (index !== -1) {
  3367. this._children.splice(index, 1);
  3368. control.parent = null;
  3369. }
  3370. control.linkWithMesh(null);
  3371. if (this._host) {
  3372. this._host._cleanControlAfterRemoval(control);
  3373. }
  3374. this._markAsDirty();
  3375. return this;
  3376. };
  3377. /** @hidden */
  3378. Container.prototype._reOrderControl = function (control) {
  3379. this.removeControl(control);
  3380. var wasAdded = false;
  3381. for (var index = 0; index < this._children.length; index++) {
  3382. if (this._children[index].zIndex > control.zIndex) {
  3383. this._children.splice(index, 0, control);
  3384. wasAdded = true;
  3385. break;
  3386. }
  3387. }
  3388. if (!wasAdded) {
  3389. this._children.push(control);
  3390. }
  3391. control.parent = this;
  3392. this._markAsDirty();
  3393. };
  3394. /** @hidden */
  3395. Container.prototype._offsetLeft = function (offset) {
  3396. _super.prototype._offsetLeft.call(this, offset);
  3397. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3398. var child = _a[_i];
  3399. child._offsetLeft(offset);
  3400. }
  3401. };
  3402. /** @hidden */
  3403. Container.prototype._offsetTop = function (offset) {
  3404. _super.prototype._offsetTop.call(this, offset);
  3405. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3406. var child = _a[_i];
  3407. child._offsetTop(offset);
  3408. }
  3409. };
  3410. /** @hidden */
  3411. Container.prototype._markAllAsDirty = function () {
  3412. _super.prototype._markAllAsDirty.call(this);
  3413. for (var index = 0; index < this._children.length; index++) {
  3414. this._children[index]._markAllAsDirty();
  3415. }
  3416. };
  3417. /** @hidden */
  3418. Container.prototype._localDraw = function (context) {
  3419. if (this._background) {
  3420. context.save();
  3421. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3422. context.shadowColor = this.shadowColor;
  3423. context.shadowBlur = this.shadowBlur;
  3424. context.shadowOffsetX = this.shadowOffsetX;
  3425. context.shadowOffsetY = this.shadowOffsetY;
  3426. }
  3427. context.fillStyle = this._background;
  3428. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3429. context.restore();
  3430. }
  3431. };
  3432. /** @hidden */
  3433. Container.prototype._link = function (host) {
  3434. _super.prototype._link.call(this, host);
  3435. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3436. var child = _a[_i];
  3437. child._link(host);
  3438. }
  3439. };
  3440. /** @hidden */
  3441. Container.prototype._beforeLayout = function () {
  3442. // Do nothing
  3443. };
  3444. /** @hidden */
  3445. Container.prototype._processMeasures = function (parentMeasure, context) {
  3446. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3447. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3448. this._evaluateClippingState(parentMeasure);
  3449. }
  3450. };
  3451. /** @hidden */
  3452. Container.prototype._layout = function (parentMeasure, context) {
  3453. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3454. return false;
  3455. }
  3456. this.host._numLayoutCalls++;
  3457. if (this._isDirty) {
  3458. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3459. }
  3460. var rebuildCount = 0;
  3461. context.save();
  3462. this._applyStates(context);
  3463. this._beforeLayout();
  3464. do {
  3465. var computedWidth = -1;
  3466. var computedHeight = -1;
  3467. this._rebuildLayout = false;
  3468. this._processMeasures(parentMeasure, context);
  3469. if (!this._isClipped) {
  3470. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3471. var child = _a[_i];
  3472. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3473. if (child._layout(this._measureForChildren, context)) {
  3474. if (this.adaptWidthToChildren && child._width.isPixel) {
  3475. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3476. }
  3477. if (this.adaptHeightToChildren && child._height.isPixel) {
  3478. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3479. }
  3480. }
  3481. }
  3482. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3483. if (this.width !== computedWidth + "px") {
  3484. this.width = computedWidth + "px";
  3485. this._rebuildLayout = true;
  3486. }
  3487. }
  3488. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3489. if (this.height !== computedHeight + "px") {
  3490. this.height = computedHeight + "px";
  3491. this._rebuildLayout = true;
  3492. }
  3493. }
  3494. this._postMeasure();
  3495. }
  3496. rebuildCount++;
  3497. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3498. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3499. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3500. }
  3501. context.restore();
  3502. if (this._isDirty) {
  3503. this.invalidateRect();
  3504. this._isDirty = false;
  3505. }
  3506. return true;
  3507. };
  3508. Container.prototype._postMeasure = function () {
  3509. // Do nothing by default
  3510. };
  3511. /** @hidden */
  3512. Container.prototype._draw = function (context, invalidatedRectangle) {
  3513. this._localDraw(context);
  3514. if (this.clipChildren) {
  3515. this._clipForChildren(context);
  3516. }
  3517. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3518. var child = _a[_i];
  3519. // Only redraw parts of the screen that are invalidated
  3520. if (invalidatedRectangle) {
  3521. if (!child._intersectsRect(invalidatedRectangle)) {
  3522. continue;
  3523. }
  3524. }
  3525. child._render(context, invalidatedRectangle);
  3526. }
  3527. };
  3528. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3529. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3530. if (!this.children) {
  3531. return;
  3532. }
  3533. for (var index = 0; index < this.children.length; index++) {
  3534. var item = this.children[index];
  3535. if (!predicate || predicate(item)) {
  3536. results.push(item);
  3537. }
  3538. if (!directDescendantsOnly) {
  3539. item.getDescendantsToRef(results, false, predicate);
  3540. }
  3541. }
  3542. };
  3543. /** @hidden */
  3544. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  3545. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3546. return false;
  3547. }
  3548. if (!_super.prototype.contains.call(this, x, y)) {
  3549. return false;
  3550. }
  3551. // Checking backwards to pick closest first
  3552. for (var index = this._children.length - 1; index >= 0; index--) {
  3553. var child = this._children[index];
  3554. if (child._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3555. if (child.hoverCursor) {
  3556. this._host._changeCursor(child.hoverCursor);
  3557. }
  3558. return true;
  3559. }
  3560. }
  3561. if (!this.isHitTestVisible) {
  3562. return false;
  3563. }
  3564. return this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  3565. };
  3566. /** @hidden */
  3567. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3568. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3569. this._measureForChildren.copyFrom(this._currentMeasure);
  3570. };
  3571. /** Releases associated resources */
  3572. Container.prototype.dispose = function () {
  3573. _super.prototype.dispose.call(this);
  3574. for (var index = this.children.length - 1; index >= 0; index--) {
  3575. this.children[index].dispose();
  3576. }
  3577. };
  3578. return Container;
  3579. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3580. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3581. /***/ }),
  3582. /***/ "./2D/controls/control.ts":
  3583. /*!********************************!*\
  3584. !*** ./2D/controls/control.ts ***!
  3585. \********************************/
  3586. /*! exports provided: Control */
  3587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3588. "use strict";
  3589. __webpack_require__.r(__webpack_exports__);
  3590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3591. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  3592. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3593. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3594. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3595. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3596. /**
  3597. * Root class used for all 2D controls
  3598. * @see http://doc.babylonjs.com/how_to/gui#controls
  3599. */
  3600. var Control = /** @class */ (function () {
  3601. // Functions
  3602. /**
  3603. * Creates a new control
  3604. * @param name defines the name of the control
  3605. */
  3606. function Control(
  3607. /** defines the name of the control */
  3608. name) {
  3609. this.name = name;
  3610. this._alpha = 1;
  3611. this._alphaSet = false;
  3612. this._zIndex = 0;
  3613. /** @hidden */
  3614. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3615. this._fontFamily = "Arial";
  3616. this._fontStyle = "";
  3617. this._fontWeight = "";
  3618. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3619. /** @hidden */
  3620. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3621. /** @hidden */
  3622. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3623. this._color = "";
  3624. this._style = null;
  3625. /** @hidden */
  3626. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3627. /** @hidden */
  3628. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3629. /** @hidden */
  3630. this._isDirty = true;
  3631. /** @hidden */
  3632. this._wasDirty = false;
  3633. /** @hidden */
  3634. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3635. /** @hidden */
  3636. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3637. /** @hidden */
  3638. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3639. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3640. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3641. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3642. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3643. /** @hidden */
  3644. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3645. /** @hidden */
  3646. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3647. this._scaleX = 1.0;
  3648. this._scaleY = 1.0;
  3649. this._rotation = 0;
  3650. this._transformCenterX = 0.5;
  3651. this._transformCenterY = 0.5;
  3652. /** @hidden */
  3653. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3654. /** @hidden */
  3655. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3656. /** @hidden */
  3657. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3658. this._isMatrixDirty = true;
  3659. this._isVisible = true;
  3660. this._isHighlighted = false;
  3661. this._fontSet = false;
  3662. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3663. this._downCount = 0;
  3664. this._enterCount = -1;
  3665. this._doNotRender = false;
  3666. this._downPointerIds = {};
  3667. this._isEnabled = true;
  3668. this._disabledColor = "#9a9a9a";
  3669. this._disabledColorItem = "#6a6a6a";
  3670. /** @hidden */
  3671. this._rebuildLayout = false;
  3672. /** @hidden */
  3673. this._customData = {};
  3674. /** @hidden */
  3675. this._isClipped = false;
  3676. /** @hidden */
  3677. this._automaticSize = false;
  3678. /**
  3679. * Gets or sets an object used to store user defined information for the node
  3680. */
  3681. this.metadata = null;
  3682. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3683. this.isHitTestVisible = true;
  3684. /** Gets or sets a boolean indicating if the control can block pointer events */
  3685. this.isPointerBlocker = false;
  3686. /** Gets or sets a boolean indicating if the control can be focusable */
  3687. this.isFocusInvisible = false;
  3688. /**
  3689. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3690. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3691. */
  3692. this.clipChildren = true;
  3693. /**
  3694. * Gets or sets a boolean indicating that control content must be clipped
  3695. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3696. */
  3697. this.clipContent = true;
  3698. /**
  3699. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3700. */
  3701. this.useBitmapCache = false;
  3702. this._shadowOffsetX = 0;
  3703. this._shadowOffsetY = 0;
  3704. this._shadowBlur = 0;
  3705. this._shadowColor = 'black';
  3706. /** Gets or sets the cursor to use when the control is hovered */
  3707. this.hoverCursor = "";
  3708. /** @hidden */
  3709. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3710. /** @hidden */
  3711. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3712. /**
  3713. * An event triggered when pointer wheel is scrolled
  3714. */
  3715. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3716. /**
  3717. * An event triggered when the pointer move over the control.
  3718. */
  3719. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3720. /**
  3721. * An event triggered when the pointer move out of the control.
  3722. */
  3723. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3724. /**
  3725. * An event triggered when the pointer taps the control
  3726. */
  3727. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3728. /**
  3729. * An event triggered when pointer up
  3730. */
  3731. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3732. /**
  3733. * An event triggered when a control is clicked on
  3734. */
  3735. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3736. /**
  3737. * An event triggered when pointer enters the control
  3738. */
  3739. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3740. /**
  3741. * An event triggered when the control is marked as dirty
  3742. */
  3743. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3744. /**
  3745. * An event triggered before drawing the control
  3746. */
  3747. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3748. /**
  3749. * An event triggered after the control was drawn
  3750. */
  3751. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3752. /**
  3753. * An event triggered when the control has been disposed
  3754. */
  3755. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3756. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3757. }
  3758. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3759. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3760. get: function () {
  3761. return this._shadowOffsetX;
  3762. },
  3763. set: function (value) {
  3764. if (this._shadowOffsetX === value) {
  3765. return;
  3766. }
  3767. this._shadowOffsetX = value;
  3768. this._markAsDirty();
  3769. },
  3770. enumerable: true,
  3771. configurable: true
  3772. });
  3773. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3774. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3775. get: function () {
  3776. return this._shadowOffsetY;
  3777. },
  3778. set: function (value) {
  3779. if (this._shadowOffsetY === value) {
  3780. return;
  3781. }
  3782. this._shadowOffsetY = value;
  3783. this._markAsDirty();
  3784. },
  3785. enumerable: true,
  3786. configurable: true
  3787. });
  3788. Object.defineProperty(Control.prototype, "shadowBlur", {
  3789. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3790. get: function () {
  3791. return this._shadowBlur;
  3792. },
  3793. set: function (value) {
  3794. if (this._shadowBlur === value) {
  3795. return;
  3796. }
  3797. this._shadowBlur = value;
  3798. this._markAsDirty();
  3799. },
  3800. enumerable: true,
  3801. configurable: true
  3802. });
  3803. Object.defineProperty(Control.prototype, "shadowColor", {
  3804. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3805. get: function () {
  3806. return this._shadowColor;
  3807. },
  3808. set: function (value) {
  3809. if (this._shadowColor === value) {
  3810. return;
  3811. }
  3812. this._shadowColor = value;
  3813. this._markAsDirty();
  3814. },
  3815. enumerable: true,
  3816. configurable: true
  3817. });
  3818. Object.defineProperty(Control.prototype, "typeName", {
  3819. // Properties
  3820. /** Gets the control type name */
  3821. get: function () {
  3822. return this._getTypeName();
  3823. },
  3824. enumerable: true,
  3825. configurable: true
  3826. });
  3827. /**
  3828. * Get the current class name of the control.
  3829. * @returns current class name
  3830. */
  3831. Control.prototype.getClassName = function () {
  3832. return this._getTypeName();
  3833. };
  3834. Object.defineProperty(Control.prototype, "host", {
  3835. /**
  3836. * Get the hosting AdvancedDynamicTexture
  3837. */
  3838. get: function () {
  3839. return this._host;
  3840. },
  3841. enumerable: true,
  3842. configurable: true
  3843. });
  3844. Object.defineProperty(Control.prototype, "fontOffset", {
  3845. /** Gets or set information about font offsets (used to render and align text) */
  3846. get: function () {
  3847. return this._fontOffset;
  3848. },
  3849. set: function (offset) {
  3850. this._fontOffset = offset;
  3851. },
  3852. enumerable: true,
  3853. configurable: true
  3854. });
  3855. Object.defineProperty(Control.prototype, "alpha", {
  3856. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3857. get: function () {
  3858. return this._alpha;
  3859. },
  3860. set: function (value) {
  3861. if (this._alpha === value) {
  3862. return;
  3863. }
  3864. this._alphaSet = true;
  3865. this._alpha = value;
  3866. this._markAsDirty();
  3867. },
  3868. enumerable: true,
  3869. configurable: true
  3870. });
  3871. Object.defineProperty(Control.prototype, "isHighlighted", {
  3872. /**
  3873. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3874. */
  3875. get: function () {
  3876. return this._isHighlighted;
  3877. },
  3878. set: function (value) {
  3879. if (this._isHighlighted === value) {
  3880. return;
  3881. }
  3882. this._isHighlighted = value;
  3883. this._markAsDirty();
  3884. },
  3885. enumerable: true,
  3886. configurable: true
  3887. });
  3888. Object.defineProperty(Control.prototype, "scaleX", {
  3889. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3890. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3891. */
  3892. get: function () {
  3893. return this._scaleX;
  3894. },
  3895. set: function (value) {
  3896. if (this._scaleX === value) {
  3897. return;
  3898. }
  3899. this._scaleX = value;
  3900. this._markAsDirty();
  3901. this._markMatrixAsDirty();
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(Control.prototype, "scaleY", {
  3907. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3908. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3909. */
  3910. get: function () {
  3911. return this._scaleY;
  3912. },
  3913. set: function (value) {
  3914. if (this._scaleY === value) {
  3915. return;
  3916. }
  3917. this._scaleY = value;
  3918. this._markAsDirty();
  3919. this._markMatrixAsDirty();
  3920. },
  3921. enumerable: true,
  3922. configurable: true
  3923. });
  3924. Object.defineProperty(Control.prototype, "rotation", {
  3925. /** Gets or sets the rotation angle (0 by default)
  3926. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3927. */
  3928. get: function () {
  3929. return this._rotation;
  3930. },
  3931. set: function (value) {
  3932. if (this._rotation === value) {
  3933. return;
  3934. }
  3935. this._rotation = value;
  3936. this._markAsDirty();
  3937. this._markMatrixAsDirty();
  3938. },
  3939. enumerable: true,
  3940. configurable: true
  3941. });
  3942. Object.defineProperty(Control.prototype, "transformCenterY", {
  3943. /** Gets or sets the transformation center on Y axis (0 by default)
  3944. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3945. */
  3946. get: function () {
  3947. return this._transformCenterY;
  3948. },
  3949. set: function (value) {
  3950. if (this._transformCenterY === value) {
  3951. return;
  3952. }
  3953. this._transformCenterY = value;
  3954. this._markAsDirty();
  3955. this._markMatrixAsDirty();
  3956. },
  3957. enumerable: true,
  3958. configurable: true
  3959. });
  3960. Object.defineProperty(Control.prototype, "transformCenterX", {
  3961. /** Gets or sets the transformation center on X axis (0 by default)
  3962. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3963. */
  3964. get: function () {
  3965. return this._transformCenterX;
  3966. },
  3967. set: function (value) {
  3968. if (this._transformCenterX === value) {
  3969. return;
  3970. }
  3971. this._transformCenterX = value;
  3972. this._markAsDirty();
  3973. this._markMatrixAsDirty();
  3974. },
  3975. enumerable: true,
  3976. configurable: true
  3977. });
  3978. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3979. /**
  3980. * Gets or sets the horizontal alignment
  3981. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3982. */
  3983. get: function () {
  3984. return this._horizontalAlignment;
  3985. },
  3986. set: function (value) {
  3987. if (this._horizontalAlignment === value) {
  3988. return;
  3989. }
  3990. this._horizontalAlignment = value;
  3991. this._markAsDirty();
  3992. },
  3993. enumerable: true,
  3994. configurable: true
  3995. });
  3996. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3997. /**
  3998. * Gets or sets the vertical alignment
  3999. * @see http://doc.babylonjs.com/how_to/gui#alignments
  4000. */
  4001. get: function () {
  4002. return this._verticalAlignment;
  4003. },
  4004. set: function (value) {
  4005. if (this._verticalAlignment === value) {
  4006. return;
  4007. }
  4008. this._verticalAlignment = value;
  4009. this._markAsDirty();
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "width", {
  4015. /**
  4016. * Gets or sets control width
  4017. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4018. */
  4019. get: function () {
  4020. return this._width.toString(this._host);
  4021. },
  4022. set: function (value) {
  4023. if (this._width.toString(this._host) === value) {
  4024. return;
  4025. }
  4026. if (this._width.fromString(value)) {
  4027. this._markAsDirty();
  4028. }
  4029. },
  4030. enumerable: true,
  4031. configurable: true
  4032. });
  4033. Object.defineProperty(Control.prototype, "widthInPixels", {
  4034. /**
  4035. * Gets or sets the control width in pixel
  4036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4037. */
  4038. get: function () {
  4039. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4040. },
  4041. set: function (value) {
  4042. if (isNaN(value)) {
  4043. return;
  4044. }
  4045. this.width = value + "px";
  4046. },
  4047. enumerable: true,
  4048. configurable: true
  4049. });
  4050. Object.defineProperty(Control.prototype, "height", {
  4051. /**
  4052. * Gets or sets control height
  4053. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4054. */
  4055. get: function () {
  4056. return this._height.toString(this._host);
  4057. },
  4058. set: function (value) {
  4059. if (this._height.toString(this._host) === value) {
  4060. return;
  4061. }
  4062. if (this._height.fromString(value)) {
  4063. this._markAsDirty();
  4064. }
  4065. },
  4066. enumerable: true,
  4067. configurable: true
  4068. });
  4069. Object.defineProperty(Control.prototype, "heightInPixels", {
  4070. /**
  4071. * Gets or sets control height in pixel
  4072. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4073. */
  4074. get: function () {
  4075. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4076. },
  4077. set: function (value) {
  4078. if (isNaN(value)) {
  4079. return;
  4080. }
  4081. this.height = value + "px";
  4082. },
  4083. enumerable: true,
  4084. configurable: true
  4085. });
  4086. Object.defineProperty(Control.prototype, "fontFamily", {
  4087. /** Gets or set font family */
  4088. get: function () {
  4089. if (!this._fontSet) {
  4090. return "";
  4091. }
  4092. return this._fontFamily;
  4093. },
  4094. set: function (value) {
  4095. if (this._fontFamily === value) {
  4096. return;
  4097. }
  4098. this._fontFamily = value;
  4099. this._resetFontCache();
  4100. },
  4101. enumerable: true,
  4102. configurable: true
  4103. });
  4104. Object.defineProperty(Control.prototype, "fontStyle", {
  4105. /** Gets or sets font style */
  4106. get: function () {
  4107. return this._fontStyle;
  4108. },
  4109. set: function (value) {
  4110. if (this._fontStyle === value) {
  4111. return;
  4112. }
  4113. this._fontStyle = value;
  4114. this._resetFontCache();
  4115. },
  4116. enumerable: true,
  4117. configurable: true
  4118. });
  4119. Object.defineProperty(Control.prototype, "fontWeight", {
  4120. /** Gets or sets font weight */
  4121. get: function () {
  4122. return this._fontWeight;
  4123. },
  4124. set: function (value) {
  4125. if (this._fontWeight === value) {
  4126. return;
  4127. }
  4128. this._fontWeight = value;
  4129. this._resetFontCache();
  4130. },
  4131. enumerable: true,
  4132. configurable: true
  4133. });
  4134. Object.defineProperty(Control.prototype, "style", {
  4135. /**
  4136. * Gets or sets style
  4137. * @see http://doc.babylonjs.com/how_to/gui#styles
  4138. */
  4139. get: function () {
  4140. return this._style;
  4141. },
  4142. set: function (value) {
  4143. var _this = this;
  4144. if (this._style) {
  4145. this._style.onChangedObservable.remove(this._styleObserver);
  4146. this._styleObserver = null;
  4147. }
  4148. this._style = value;
  4149. if (this._style) {
  4150. this._styleObserver = this._style.onChangedObservable.add(function () {
  4151. _this._markAsDirty();
  4152. _this._resetFontCache();
  4153. });
  4154. }
  4155. this._markAsDirty();
  4156. this._resetFontCache();
  4157. },
  4158. enumerable: true,
  4159. configurable: true
  4160. });
  4161. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4162. /** @hidden */
  4163. get: function () {
  4164. return this._fontSize.isPercentage;
  4165. },
  4166. enumerable: true,
  4167. configurable: true
  4168. });
  4169. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4170. /** Gets or sets font size in pixels */
  4171. get: function () {
  4172. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4173. if (fontSizeToUse.isPixel) {
  4174. return fontSizeToUse.getValue(this._host);
  4175. }
  4176. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4177. },
  4178. set: function (value) {
  4179. if (isNaN(value)) {
  4180. return;
  4181. }
  4182. this.fontSize = value + "px";
  4183. },
  4184. enumerable: true,
  4185. configurable: true
  4186. });
  4187. Object.defineProperty(Control.prototype, "fontSize", {
  4188. /** Gets or sets font size */
  4189. get: function () {
  4190. return this._fontSize.toString(this._host);
  4191. },
  4192. set: function (value) {
  4193. if (this._fontSize.toString(this._host) === value) {
  4194. return;
  4195. }
  4196. if (this._fontSize.fromString(value)) {
  4197. this._markAsDirty();
  4198. this._resetFontCache();
  4199. }
  4200. },
  4201. enumerable: true,
  4202. configurable: true
  4203. });
  4204. Object.defineProperty(Control.prototype, "color", {
  4205. /** Gets or sets foreground color */
  4206. get: function () {
  4207. return this._color;
  4208. },
  4209. set: function (value) {
  4210. if (this._color === value) {
  4211. return;
  4212. }
  4213. this._color = value;
  4214. this._markAsDirty();
  4215. },
  4216. enumerable: true,
  4217. configurable: true
  4218. });
  4219. Object.defineProperty(Control.prototype, "zIndex", {
  4220. /** Gets or sets z index which is used to reorder controls on the z axis */
  4221. get: function () {
  4222. return this._zIndex;
  4223. },
  4224. set: function (value) {
  4225. if (this.zIndex === value) {
  4226. return;
  4227. }
  4228. this._zIndex = value;
  4229. if (this.parent) {
  4230. this.parent._reOrderControl(this);
  4231. }
  4232. },
  4233. enumerable: true,
  4234. configurable: true
  4235. });
  4236. Object.defineProperty(Control.prototype, "notRenderable", {
  4237. /** Gets or sets a boolean indicating if the control can be rendered */
  4238. get: function () {
  4239. return this._doNotRender;
  4240. },
  4241. set: function (value) {
  4242. if (this._doNotRender === value) {
  4243. return;
  4244. }
  4245. this._doNotRender = value;
  4246. this._markAsDirty();
  4247. },
  4248. enumerable: true,
  4249. configurable: true
  4250. });
  4251. Object.defineProperty(Control.prototype, "isVisible", {
  4252. /** Gets or sets a boolean indicating if the control is visible */
  4253. get: function () {
  4254. return this._isVisible;
  4255. },
  4256. set: function (value) {
  4257. if (this._isVisible === value) {
  4258. return;
  4259. }
  4260. this._isVisible = value;
  4261. this._markAsDirty(true);
  4262. },
  4263. enumerable: true,
  4264. configurable: true
  4265. });
  4266. Object.defineProperty(Control.prototype, "isDirty", {
  4267. /** Gets a boolean indicating that the control needs to update its rendering */
  4268. get: function () {
  4269. return this._isDirty;
  4270. },
  4271. enumerable: true,
  4272. configurable: true
  4273. });
  4274. Object.defineProperty(Control.prototype, "linkedMesh", {
  4275. /**
  4276. * Gets the current linked mesh (or null if none)
  4277. */
  4278. get: function () {
  4279. return this._linkedMesh;
  4280. },
  4281. enumerable: true,
  4282. configurable: true
  4283. });
  4284. Object.defineProperty(Control.prototype, "paddingLeft", {
  4285. /**
  4286. * Gets or sets a value indicating the padding to use on the left of the control
  4287. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4288. */
  4289. get: function () {
  4290. return this._paddingLeft.toString(this._host);
  4291. },
  4292. set: function (value) {
  4293. if (this._paddingLeft.fromString(value)) {
  4294. this._markAsDirty();
  4295. }
  4296. },
  4297. enumerable: true,
  4298. configurable: true
  4299. });
  4300. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4301. /**
  4302. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4303. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4304. */
  4305. get: function () {
  4306. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4307. },
  4308. set: function (value) {
  4309. if (isNaN(value)) {
  4310. return;
  4311. }
  4312. this.paddingLeft = value + "px";
  4313. },
  4314. enumerable: true,
  4315. configurable: true
  4316. });
  4317. Object.defineProperty(Control.prototype, "paddingRight", {
  4318. /**
  4319. * Gets or sets a value indicating the padding to use on the right of the control
  4320. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4321. */
  4322. get: function () {
  4323. return this._paddingRight.toString(this._host);
  4324. },
  4325. set: function (value) {
  4326. if (this._paddingRight.fromString(value)) {
  4327. this._markAsDirty();
  4328. }
  4329. },
  4330. enumerable: true,
  4331. configurable: true
  4332. });
  4333. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4334. /**
  4335. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4336. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4337. */
  4338. get: function () {
  4339. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4340. },
  4341. set: function (value) {
  4342. if (isNaN(value)) {
  4343. return;
  4344. }
  4345. this.paddingRight = value + "px";
  4346. },
  4347. enumerable: true,
  4348. configurable: true
  4349. });
  4350. Object.defineProperty(Control.prototype, "paddingTop", {
  4351. /**
  4352. * Gets or sets a value indicating the padding to use on the top of the control
  4353. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4354. */
  4355. get: function () {
  4356. return this._paddingTop.toString(this._host);
  4357. },
  4358. set: function (value) {
  4359. if (this._paddingTop.fromString(value)) {
  4360. this._markAsDirty();
  4361. }
  4362. },
  4363. enumerable: true,
  4364. configurable: true
  4365. });
  4366. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4367. /**
  4368. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4369. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4370. */
  4371. get: function () {
  4372. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4373. },
  4374. set: function (value) {
  4375. if (isNaN(value)) {
  4376. return;
  4377. }
  4378. this.paddingTop = value + "px";
  4379. },
  4380. enumerable: true,
  4381. configurable: true
  4382. });
  4383. Object.defineProperty(Control.prototype, "paddingBottom", {
  4384. /**
  4385. * Gets or sets a value indicating the padding to use on the bottom of the control
  4386. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4387. */
  4388. get: function () {
  4389. return this._paddingBottom.toString(this._host);
  4390. },
  4391. set: function (value) {
  4392. if (this._paddingBottom.fromString(value)) {
  4393. this._markAsDirty();
  4394. }
  4395. },
  4396. enumerable: true,
  4397. configurable: true
  4398. });
  4399. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4400. /**
  4401. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4402. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4403. */
  4404. get: function () {
  4405. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4406. },
  4407. set: function (value) {
  4408. if (isNaN(value)) {
  4409. return;
  4410. }
  4411. this.paddingBottom = value + "px";
  4412. },
  4413. enumerable: true,
  4414. configurable: true
  4415. });
  4416. Object.defineProperty(Control.prototype, "left", {
  4417. /**
  4418. * Gets or sets a value indicating the left coordinate of the control
  4419. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4420. */
  4421. get: function () {
  4422. return this._left.toString(this._host);
  4423. },
  4424. set: function (value) {
  4425. if (this._left.fromString(value)) {
  4426. this._markAsDirty();
  4427. }
  4428. },
  4429. enumerable: true,
  4430. configurable: true
  4431. });
  4432. Object.defineProperty(Control.prototype, "leftInPixels", {
  4433. /**
  4434. * Gets or sets a value indicating the left coordinate in pixels of the control
  4435. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4436. */
  4437. get: function () {
  4438. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4439. },
  4440. set: function (value) {
  4441. if (isNaN(value)) {
  4442. return;
  4443. }
  4444. this.left = value + "px";
  4445. },
  4446. enumerable: true,
  4447. configurable: true
  4448. });
  4449. Object.defineProperty(Control.prototype, "top", {
  4450. /**
  4451. * Gets or sets a value indicating the top coordinate of the control
  4452. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4453. */
  4454. get: function () {
  4455. return this._top.toString(this._host);
  4456. },
  4457. set: function (value) {
  4458. if (this._top.fromString(value)) {
  4459. this._markAsDirty();
  4460. }
  4461. },
  4462. enumerable: true,
  4463. configurable: true
  4464. });
  4465. Object.defineProperty(Control.prototype, "topInPixels", {
  4466. /**
  4467. * Gets or sets a value indicating the top coordinate in pixels of the control
  4468. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4469. */
  4470. get: function () {
  4471. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4472. },
  4473. set: function (value) {
  4474. if (isNaN(value)) {
  4475. return;
  4476. }
  4477. this.top = value + "px";
  4478. },
  4479. enumerable: true,
  4480. configurable: true
  4481. });
  4482. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4483. /**
  4484. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4485. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4486. */
  4487. get: function () {
  4488. return this._linkOffsetX.toString(this._host);
  4489. },
  4490. set: function (value) {
  4491. if (this._linkOffsetX.fromString(value)) {
  4492. this._markAsDirty();
  4493. }
  4494. },
  4495. enumerable: true,
  4496. configurable: true
  4497. });
  4498. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4499. /**
  4500. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4501. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4502. */
  4503. get: function () {
  4504. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4505. },
  4506. set: function (value) {
  4507. if (isNaN(value)) {
  4508. return;
  4509. }
  4510. this.linkOffsetX = value + "px";
  4511. },
  4512. enumerable: true,
  4513. configurable: true
  4514. });
  4515. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4516. /**
  4517. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4518. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4519. */
  4520. get: function () {
  4521. return this._linkOffsetY.toString(this._host);
  4522. },
  4523. set: function (value) {
  4524. if (this._linkOffsetY.fromString(value)) {
  4525. this._markAsDirty();
  4526. }
  4527. },
  4528. enumerable: true,
  4529. configurable: true
  4530. });
  4531. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4532. /**
  4533. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4534. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4535. */
  4536. get: function () {
  4537. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4538. },
  4539. set: function (value) {
  4540. if (isNaN(value)) {
  4541. return;
  4542. }
  4543. this.linkOffsetY = value + "px";
  4544. },
  4545. enumerable: true,
  4546. configurable: true
  4547. });
  4548. Object.defineProperty(Control.prototype, "centerX", {
  4549. /** Gets the center coordinate on X axis */
  4550. get: function () {
  4551. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4552. },
  4553. enumerable: true,
  4554. configurable: true
  4555. });
  4556. Object.defineProperty(Control.prototype, "centerY", {
  4557. /** Gets the center coordinate on Y axis */
  4558. get: function () {
  4559. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4560. },
  4561. enumerable: true,
  4562. configurable: true
  4563. });
  4564. Object.defineProperty(Control.prototype, "isEnabled", {
  4565. /** Gets or sets if control is Enabled*/
  4566. get: function () {
  4567. return this._isEnabled;
  4568. },
  4569. set: function (value) {
  4570. if (this._isEnabled === value) {
  4571. return;
  4572. }
  4573. this._isEnabled = value;
  4574. this._markAsDirty();
  4575. },
  4576. enumerable: true,
  4577. configurable: true
  4578. });
  4579. Object.defineProperty(Control.prototype, "disabledColor", {
  4580. /** Gets or sets background color of control if it's disabled*/
  4581. get: function () {
  4582. return this._disabledColor;
  4583. },
  4584. set: function (value) {
  4585. if (this._disabledColor === value) {
  4586. return;
  4587. }
  4588. this._disabledColor = value;
  4589. this._markAsDirty();
  4590. },
  4591. enumerable: true,
  4592. configurable: true
  4593. });
  4594. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4595. /** Gets or sets front color of control if it's disabled*/
  4596. get: function () {
  4597. return this._disabledColorItem;
  4598. },
  4599. set: function (value) {
  4600. if (this._disabledColorItem === value) {
  4601. return;
  4602. }
  4603. this._disabledColorItem = value;
  4604. this._markAsDirty();
  4605. },
  4606. enumerable: true,
  4607. configurable: true
  4608. });
  4609. /** @hidden */
  4610. Control.prototype._getTypeName = function () {
  4611. return "Control";
  4612. };
  4613. /**
  4614. * Gets the first ascendant in the hierarchy of the given type
  4615. * @param className defines the required type
  4616. * @returns the ascendant or null if not found
  4617. */
  4618. Control.prototype.getAscendantOfClass = function (className) {
  4619. if (!this.parent) {
  4620. return null;
  4621. }
  4622. if (this.parent.getClassName() === className) {
  4623. return this.parent;
  4624. }
  4625. return this.parent.getAscendantOfClass(className);
  4626. };
  4627. /** @hidden */
  4628. Control.prototype._resetFontCache = function () {
  4629. this._fontSet = true;
  4630. this._markAsDirty();
  4631. };
  4632. /**
  4633. * Determines if a container is an ascendant of the current control
  4634. * @param container defines the container to look for
  4635. * @returns true if the container is one of the ascendant of the control
  4636. */
  4637. Control.prototype.isAscendant = function (container) {
  4638. if (!this.parent) {
  4639. return false;
  4640. }
  4641. if (this.parent === container) {
  4642. return true;
  4643. }
  4644. return this.parent.isAscendant(container);
  4645. };
  4646. /**
  4647. * Gets coordinates in local control space
  4648. * @param globalCoordinates defines the coordinates to transform
  4649. * @returns the new coordinates in local space
  4650. */
  4651. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4652. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4653. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4654. return result;
  4655. };
  4656. /**
  4657. * Gets coordinates in local control space
  4658. * @param globalCoordinates defines the coordinates to transform
  4659. * @param result defines the target vector2 where to store the result
  4660. * @returns the current control
  4661. */
  4662. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4663. result.x = globalCoordinates.x - this._currentMeasure.left;
  4664. result.y = globalCoordinates.y - this._currentMeasure.top;
  4665. return this;
  4666. };
  4667. /**
  4668. * Gets coordinates in parent local control space
  4669. * @param globalCoordinates defines the coordinates to transform
  4670. * @returns the new coordinates in parent local space
  4671. */
  4672. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4673. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4674. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4675. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4676. return result;
  4677. };
  4678. /**
  4679. * Move the current control to a vector3 position projected onto the screen.
  4680. * @param position defines the target position
  4681. * @param scene defines the hosting scene
  4682. */
  4683. Control.prototype.moveToVector3 = function (position, scene) {
  4684. if (!this._host || this.parent !== this._host._rootContainer) {
  4685. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4686. return;
  4687. }
  4688. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4689. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4690. var globalViewport = this._host._getGlobalViewport(scene);
  4691. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4692. this._moveToProjectedPosition(projectedPosition);
  4693. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4694. this.notRenderable = true;
  4695. return;
  4696. }
  4697. this.notRenderable = false;
  4698. };
  4699. /**
  4700. * Will store all controls that have this control as ascendant in a given array
  4701. * @param results defines the array where to store the descendants
  4702. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4703. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4704. */
  4705. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4706. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4707. // Do nothing by default
  4708. };
  4709. /**
  4710. * Will return all controls that have this control as ascendant
  4711. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4712. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4713. * @return all child controls
  4714. */
  4715. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4716. var results = new Array();
  4717. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4718. return results;
  4719. };
  4720. /**
  4721. * Link current control with a target mesh
  4722. * @param mesh defines the mesh to link with
  4723. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4724. */
  4725. Control.prototype.linkWithMesh = function (mesh) {
  4726. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4727. if (mesh) {
  4728. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4729. }
  4730. return;
  4731. }
  4732. var index = this._host._linkedControls.indexOf(this);
  4733. if (index !== -1) {
  4734. this._linkedMesh = mesh;
  4735. if (!mesh) {
  4736. this._host._linkedControls.splice(index, 1);
  4737. }
  4738. return;
  4739. }
  4740. else if (!mesh) {
  4741. return;
  4742. }
  4743. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4744. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4745. this._linkedMesh = mesh;
  4746. this._host._linkedControls.push(this);
  4747. };
  4748. /** @hidden */
  4749. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4750. var oldLeft = this._left.getValue(this._host);
  4751. var oldTop = this._top.getValue(this._host);
  4752. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4753. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4754. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4755. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4756. newLeft = oldLeft;
  4757. }
  4758. if (Math.abs(newTop - oldTop) < 0.5) {
  4759. newTop = oldTop;
  4760. }
  4761. }
  4762. this.left = newLeft + "px";
  4763. this.top = newTop + "px";
  4764. this._left.ignoreAdaptiveScaling = true;
  4765. this._top.ignoreAdaptiveScaling = true;
  4766. this._markAsDirty();
  4767. };
  4768. /** @hidden */
  4769. Control.prototype._offsetLeft = function (offset) {
  4770. this._isDirty = true;
  4771. this._currentMeasure.left += offset;
  4772. };
  4773. /** @hidden */
  4774. Control.prototype._offsetTop = function (offset) {
  4775. this._isDirty = true;
  4776. this._currentMeasure.top += offset;
  4777. };
  4778. /** @hidden */
  4779. Control.prototype._markMatrixAsDirty = function () {
  4780. this._isMatrixDirty = true;
  4781. this._flagDescendantsAsMatrixDirty();
  4782. };
  4783. /** @hidden */
  4784. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4785. // No child
  4786. };
  4787. /** @hidden */
  4788. Control.prototype._intersectsRect = function (rect) {
  4789. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4790. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4791. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4792. return false;
  4793. }
  4794. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4795. return false;
  4796. }
  4797. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4798. return false;
  4799. }
  4800. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4801. return false;
  4802. }
  4803. return true;
  4804. };
  4805. /** @hidden */
  4806. Control.prototype.invalidateRect = function () {
  4807. this._transform();
  4808. if (this.host && this.host.useInvalidateRectOptimization) {
  4809. // Rotate by transform to get the measure transformed to global space
  4810. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4811. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4812. // the previous measure is used to properly clear a control that is scaled down
  4813. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4814. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4815. // Expand rect based on shadows
  4816. var shadowOffsetX = this.shadowOffsetX;
  4817. var shadowOffsetY = this.shadowOffsetY;
  4818. var shadowBlur = this.shadowBlur;
  4819. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4820. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4821. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4822. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4823. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left + leftShadowOffset), Math.floor(this._tmpMeasureA.top + topShadowOffset), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width + rightShadowOffset), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height + bottomShadowOffset));
  4824. }
  4825. else {
  4826. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4827. }
  4828. }
  4829. };
  4830. /** @hidden */
  4831. Control.prototype._markAsDirty = function (force) {
  4832. if (force === void 0) { force = false; }
  4833. if (!this._isVisible && !force) {
  4834. return;
  4835. }
  4836. this._isDirty = true;
  4837. // Redraw only this rectangle
  4838. if (this._host) {
  4839. this._host.markAsDirty();
  4840. }
  4841. };
  4842. /** @hidden */
  4843. Control.prototype._markAllAsDirty = function () {
  4844. this._markAsDirty();
  4845. if (this._font) {
  4846. this._prepareFont();
  4847. }
  4848. };
  4849. /** @hidden */
  4850. Control.prototype._link = function (host) {
  4851. this._host = host;
  4852. if (this._host) {
  4853. this.uniqueId = this._host.getScene().getUniqueId();
  4854. }
  4855. };
  4856. /** @hidden */
  4857. Control.prototype._transform = function (context) {
  4858. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4859. return;
  4860. }
  4861. // postTranslate
  4862. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4863. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4864. if (context) {
  4865. context.translate(offsetX, offsetY);
  4866. // rotate
  4867. context.rotate(this._rotation);
  4868. // scale
  4869. context.scale(this._scaleX, this._scaleY);
  4870. // preTranslate
  4871. context.translate(-offsetX, -offsetY);
  4872. }
  4873. // Need to update matrices?
  4874. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4875. this._cachedOffsetX = offsetX;
  4876. this._cachedOffsetY = offsetY;
  4877. this._isMatrixDirty = false;
  4878. this._flagDescendantsAsMatrixDirty();
  4879. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4880. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4881. }
  4882. };
  4883. /** @hidden */
  4884. Control.prototype._renderHighlight = function (context) {
  4885. if (!this.isHighlighted) {
  4886. return;
  4887. }
  4888. context.save();
  4889. context.strokeStyle = "#4affff";
  4890. context.lineWidth = 2;
  4891. this._renderHighlightSpecific(context);
  4892. context.restore();
  4893. };
  4894. /** @hidden */
  4895. Control.prototype._renderHighlightSpecific = function (context) {
  4896. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4897. };
  4898. /** @hidden */
  4899. Control.prototype._applyStates = function (context) {
  4900. if (this._isFontSizeInPercentage) {
  4901. this._fontSet = true;
  4902. }
  4903. if (this._fontSet) {
  4904. this._prepareFont();
  4905. this._fontSet = false;
  4906. }
  4907. if (this._font) {
  4908. context.font = this._font;
  4909. }
  4910. if (this._color) {
  4911. context.fillStyle = this._color;
  4912. }
  4913. if (Control.AllowAlphaInheritance) {
  4914. context.globalAlpha *= this._alpha;
  4915. }
  4916. else if (this._alphaSet) {
  4917. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4918. }
  4919. };
  4920. /** @hidden */
  4921. Control.prototype._layout = function (parentMeasure, context) {
  4922. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4923. return false;
  4924. }
  4925. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4926. this.host._numLayoutCalls++;
  4927. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4928. context.save();
  4929. this._applyStates(context);
  4930. var rebuildCount = 0;
  4931. do {
  4932. this._rebuildLayout = false;
  4933. this._processMeasures(parentMeasure, context);
  4934. rebuildCount++;
  4935. } while (this._rebuildLayout && rebuildCount < 3);
  4936. if (rebuildCount >= 3) {
  4937. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4938. }
  4939. context.restore();
  4940. this.invalidateRect();
  4941. this._evaluateClippingState(parentMeasure);
  4942. }
  4943. this._wasDirty = this._isDirty;
  4944. this._isDirty = false;
  4945. return true;
  4946. };
  4947. /** @hidden */
  4948. Control.prototype._processMeasures = function (parentMeasure, context) {
  4949. this._currentMeasure.copyFrom(parentMeasure);
  4950. // Let children take some pre-measurement actions
  4951. this._preMeasure(parentMeasure, context);
  4952. this._measure();
  4953. this._computeAlignment(parentMeasure, context);
  4954. // Convert to int values
  4955. this._currentMeasure.left = this._currentMeasure.left | 0;
  4956. this._currentMeasure.top = this._currentMeasure.top | 0;
  4957. this._currentMeasure.width = this._currentMeasure.width | 0;
  4958. this._currentMeasure.height = this._currentMeasure.height | 0;
  4959. // Let children add more features
  4960. this._additionalProcessing(parentMeasure, context);
  4961. this._cachedParentMeasure.copyFrom(parentMeasure);
  4962. if (this.onDirtyObservable.hasObservers()) {
  4963. this.onDirtyObservable.notifyObservers(this);
  4964. }
  4965. };
  4966. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4967. if (this.parent && this.parent.clipChildren) {
  4968. // Early clip
  4969. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4970. this._isClipped = true;
  4971. return;
  4972. }
  4973. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4974. this._isClipped = true;
  4975. return;
  4976. }
  4977. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4978. this._isClipped = true;
  4979. return;
  4980. }
  4981. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4982. this._isClipped = true;
  4983. return;
  4984. }
  4985. }
  4986. this._isClipped = false;
  4987. };
  4988. /** @hidden */
  4989. Control.prototype._measure = function () {
  4990. // Width / Height
  4991. if (this._width.isPixel) {
  4992. this._currentMeasure.width = this._width.getValue(this._host);
  4993. }
  4994. else {
  4995. this._currentMeasure.width *= this._width.getValue(this._host);
  4996. }
  4997. if (this._height.isPixel) {
  4998. this._currentMeasure.height = this._height.getValue(this._host);
  4999. }
  5000. else {
  5001. this._currentMeasure.height *= this._height.getValue(this._host);
  5002. }
  5003. };
  5004. /** @hidden */
  5005. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5006. var width = this._currentMeasure.width;
  5007. var height = this._currentMeasure.height;
  5008. var parentWidth = parentMeasure.width;
  5009. var parentHeight = parentMeasure.height;
  5010. // Left / top
  5011. var x = 0;
  5012. var y = 0;
  5013. switch (this.horizontalAlignment) {
  5014. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5015. x = 0;
  5016. break;
  5017. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5018. x = parentWidth - width;
  5019. break;
  5020. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5021. x = (parentWidth - width) / 2;
  5022. break;
  5023. }
  5024. switch (this.verticalAlignment) {
  5025. case Control.VERTICAL_ALIGNMENT_TOP:
  5026. y = 0;
  5027. break;
  5028. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5029. y = parentHeight - height;
  5030. break;
  5031. case Control.VERTICAL_ALIGNMENT_CENTER:
  5032. y = (parentHeight - height) / 2;
  5033. break;
  5034. }
  5035. if (this._paddingLeft.isPixel) {
  5036. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5037. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5038. }
  5039. else {
  5040. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5041. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5042. }
  5043. if (this._paddingRight.isPixel) {
  5044. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5045. }
  5046. else {
  5047. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5048. }
  5049. if (this._paddingTop.isPixel) {
  5050. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5051. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5052. }
  5053. else {
  5054. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5055. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5056. }
  5057. if (this._paddingBottom.isPixel) {
  5058. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5059. }
  5060. else {
  5061. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5062. }
  5063. if (this._left.isPixel) {
  5064. this._currentMeasure.left += this._left.getValue(this._host);
  5065. }
  5066. else {
  5067. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5068. }
  5069. if (this._top.isPixel) {
  5070. this._currentMeasure.top += this._top.getValue(this._host);
  5071. }
  5072. else {
  5073. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5074. }
  5075. this._currentMeasure.left += x;
  5076. this._currentMeasure.top += y;
  5077. };
  5078. /** @hidden */
  5079. Control.prototype._preMeasure = function (parentMeasure, context) {
  5080. // Do nothing
  5081. };
  5082. /** @hidden */
  5083. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5084. // Do nothing
  5085. };
  5086. /** @hidden */
  5087. Control.prototype._clipForChildren = function (context) {
  5088. // DO nothing
  5089. };
  5090. Control.prototype._clip = function (context, invalidatedRectangle) {
  5091. context.beginPath();
  5092. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5093. if (invalidatedRectangle) {
  5094. // Rotate the invalidated rect into the control's space
  5095. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5096. // Get the intersection of the rect in context space and the current context
  5097. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5098. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5099. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5100. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5101. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5102. Control._ClipMeasure.copyFrom(intersection);
  5103. }
  5104. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5105. var shadowOffsetX = this.shadowOffsetX;
  5106. var shadowOffsetY = this.shadowOffsetY;
  5107. var shadowBlur = this.shadowBlur;
  5108. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5109. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5110. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5111. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5112. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5113. }
  5114. else {
  5115. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5116. }
  5117. context.clip();
  5118. };
  5119. /** @hidden */
  5120. Control.prototype._render = function (context, invalidatedRectangle) {
  5121. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5122. this._isDirty = false;
  5123. return false;
  5124. }
  5125. this.host._numRenderCalls++;
  5126. context.save();
  5127. this._applyStates(context);
  5128. // Transform
  5129. this._transform(context);
  5130. // Clip
  5131. if (this.clipContent) {
  5132. this._clip(context, invalidatedRectangle);
  5133. }
  5134. if (this.onBeforeDrawObservable.hasObservers()) {
  5135. this.onBeforeDrawObservable.notifyObservers(this);
  5136. }
  5137. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5138. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5139. }
  5140. else {
  5141. this._draw(context, invalidatedRectangle);
  5142. }
  5143. if (this.useBitmapCache && this._wasDirty) {
  5144. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5145. }
  5146. this._renderHighlight(context);
  5147. if (this.onAfterDrawObservable.hasObservers()) {
  5148. this.onAfterDrawObservable.notifyObservers(this);
  5149. }
  5150. context.restore();
  5151. return true;
  5152. };
  5153. /** @hidden */
  5154. Control.prototype._draw = function (context, invalidatedRectangle) {
  5155. // Do nothing
  5156. };
  5157. /**
  5158. * Tests if a given coordinates belong to the current control
  5159. * @param x defines x coordinate to test
  5160. * @param y defines y coordinate to test
  5161. * @returns true if the coordinates are inside the control
  5162. */
  5163. Control.prototype.contains = function (x, y) {
  5164. // Invert transform
  5165. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5166. x = this._transformedPosition.x;
  5167. y = this._transformedPosition.y;
  5168. // Check
  5169. if (x < this._currentMeasure.left) {
  5170. return false;
  5171. }
  5172. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5173. return false;
  5174. }
  5175. if (y < this._currentMeasure.top) {
  5176. return false;
  5177. }
  5178. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5179. return false;
  5180. }
  5181. if (this.isPointerBlocker) {
  5182. this._host._shouldBlockPointer = true;
  5183. }
  5184. return true;
  5185. };
  5186. /** @hidden */
  5187. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5188. if (!this._isEnabled) {
  5189. return false;
  5190. }
  5191. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5192. return false;
  5193. }
  5194. if (!this.contains(x, y)) {
  5195. return false;
  5196. }
  5197. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5198. return true;
  5199. };
  5200. /** @hidden */
  5201. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5202. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5203. if (canNotify && this.parent != null) {
  5204. this.parent._onPointerMove(target, coordinates, pointerId);
  5205. }
  5206. };
  5207. /** @hidden */
  5208. Control.prototype._onPointerEnter = function (target) {
  5209. if (!this._isEnabled) {
  5210. return false;
  5211. }
  5212. if (this._enterCount > 0) {
  5213. return false;
  5214. }
  5215. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5216. this._enterCount = 0;
  5217. }
  5218. this._enterCount++;
  5219. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5220. if (canNotify && this.parent != null) {
  5221. this.parent._onPointerEnter(target);
  5222. }
  5223. return true;
  5224. };
  5225. /** @hidden */
  5226. Control.prototype._onPointerOut = function (target, force) {
  5227. if (force === void 0) { force = false; }
  5228. if (!force && (!this._isEnabled || target === this)) {
  5229. return;
  5230. }
  5231. this._enterCount = 0;
  5232. var canNotify = true;
  5233. if (!target.isAscendant(this)) {
  5234. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5235. }
  5236. if (canNotify && this.parent != null) {
  5237. this.parent._onPointerOut(target, force);
  5238. }
  5239. };
  5240. /** @hidden */
  5241. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5242. // Prevent pointerout to lose control context.
  5243. // Event redundancy is checked inside the function.
  5244. this._onPointerEnter(this);
  5245. if (this._downCount !== 0) {
  5246. return false;
  5247. }
  5248. this._downCount++;
  5249. this._downPointerIds[pointerId] = true;
  5250. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5251. if (canNotify && this.parent != null) {
  5252. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5253. }
  5254. return true;
  5255. };
  5256. /** @hidden */
  5257. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5258. if (!this._isEnabled) {
  5259. return;
  5260. }
  5261. this._downCount = 0;
  5262. delete this._downPointerIds[pointerId];
  5263. var canNotifyClick = notifyClick;
  5264. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5265. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5266. }
  5267. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5268. if (canNotify && this.parent != null) {
  5269. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5270. }
  5271. };
  5272. /** @hidden */
  5273. Control.prototype._forcePointerUp = function (pointerId) {
  5274. if (pointerId === void 0) { pointerId = null; }
  5275. if (pointerId !== null) {
  5276. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5277. }
  5278. else {
  5279. for (var key in this._downPointerIds) {
  5280. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5281. }
  5282. }
  5283. };
  5284. /** @hidden */
  5285. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5286. if (!this._isEnabled) {
  5287. return;
  5288. }
  5289. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5290. if (canNotify && this.parent != null) {
  5291. this.parent._onWheelScroll(deltaX, deltaY);
  5292. }
  5293. };
  5294. /** @hidden */
  5295. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5296. if (!this._isEnabled) {
  5297. return false;
  5298. }
  5299. this._dummyVector2.copyFromFloats(x, y);
  5300. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5301. this._onPointerMove(this, this._dummyVector2, pointerId);
  5302. var previousControlOver = this._host._lastControlOver[pointerId];
  5303. if (previousControlOver && previousControlOver !== this) {
  5304. previousControlOver._onPointerOut(this);
  5305. }
  5306. if (previousControlOver !== this) {
  5307. this._onPointerEnter(this);
  5308. }
  5309. this._host._lastControlOver[pointerId] = this;
  5310. return true;
  5311. }
  5312. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5313. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5314. this._host._registerLastControlDown(this, pointerId);
  5315. this._host._lastPickedControl = this;
  5316. return true;
  5317. }
  5318. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5319. if (this._host._lastControlDown[pointerId]) {
  5320. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5321. }
  5322. delete this._host._lastControlDown[pointerId];
  5323. return true;
  5324. }
  5325. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5326. if (this._host._lastControlOver[pointerId]) {
  5327. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5328. return true;
  5329. }
  5330. }
  5331. return false;
  5332. };
  5333. Control.prototype._prepareFont = function () {
  5334. if (!this._font && !this._fontSet) {
  5335. return;
  5336. }
  5337. if (this._style) {
  5338. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5339. }
  5340. else {
  5341. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5342. }
  5343. this._fontOffset = Control._GetFontOffset(this._font);
  5344. };
  5345. /** Releases associated resources */
  5346. Control.prototype.dispose = function () {
  5347. this.onDirtyObservable.clear();
  5348. this.onBeforeDrawObservable.clear();
  5349. this.onAfterDrawObservable.clear();
  5350. this.onPointerDownObservable.clear();
  5351. this.onPointerEnterObservable.clear();
  5352. this.onPointerMoveObservable.clear();
  5353. this.onPointerOutObservable.clear();
  5354. this.onPointerUpObservable.clear();
  5355. this.onPointerClickObservable.clear();
  5356. this.onWheelObservable.clear();
  5357. if (this._styleObserver && this._style) {
  5358. this._style.onChangedObservable.remove(this._styleObserver);
  5359. this._styleObserver = null;
  5360. }
  5361. if (this.parent) {
  5362. this.parent.removeControl(this);
  5363. this.parent = null;
  5364. }
  5365. if (this._host) {
  5366. var index = this._host._linkedControls.indexOf(this);
  5367. if (index > -1) {
  5368. this.linkWithMesh(null);
  5369. }
  5370. }
  5371. // Callback
  5372. this.onDisposeObservable.notifyObservers(this);
  5373. this.onDisposeObservable.clear();
  5374. };
  5375. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5376. /** HORIZONTAL_ALIGNMENT_LEFT */
  5377. get: function () {
  5378. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5379. },
  5380. enumerable: true,
  5381. configurable: true
  5382. });
  5383. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5384. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5385. get: function () {
  5386. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5387. },
  5388. enumerable: true,
  5389. configurable: true
  5390. });
  5391. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5392. /** HORIZONTAL_ALIGNMENT_CENTER */
  5393. get: function () {
  5394. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5395. },
  5396. enumerable: true,
  5397. configurable: true
  5398. });
  5399. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5400. /** VERTICAL_ALIGNMENT_TOP */
  5401. get: function () {
  5402. return Control._VERTICAL_ALIGNMENT_TOP;
  5403. },
  5404. enumerable: true,
  5405. configurable: true
  5406. });
  5407. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5408. /** VERTICAL_ALIGNMENT_BOTTOM */
  5409. get: function () {
  5410. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5411. },
  5412. enumerable: true,
  5413. configurable: true
  5414. });
  5415. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5416. /** VERTICAL_ALIGNMENT_CENTER */
  5417. get: function () {
  5418. return Control._VERTICAL_ALIGNMENT_CENTER;
  5419. },
  5420. enumerable: true,
  5421. configurable: true
  5422. });
  5423. /** @hidden */
  5424. Control._GetFontOffset = function (font) {
  5425. if (Control._FontHeightSizes[font]) {
  5426. return Control._FontHeightSizes[font];
  5427. }
  5428. var text = document.createElement("span");
  5429. text.innerHTML = "Hg";
  5430. text.style.font = font;
  5431. var block = document.createElement("div");
  5432. block.style.display = "inline-block";
  5433. block.style.width = "1px";
  5434. block.style.height = "0px";
  5435. block.style.verticalAlign = "bottom";
  5436. var div = document.createElement("div");
  5437. div.appendChild(text);
  5438. div.appendChild(block);
  5439. document.body.appendChild(div);
  5440. var fontAscent = 0;
  5441. var fontHeight = 0;
  5442. try {
  5443. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5444. block.style.verticalAlign = "baseline";
  5445. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5446. }
  5447. finally {
  5448. document.body.removeChild(div);
  5449. }
  5450. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5451. Control._FontHeightSizes[font] = result;
  5452. return result;
  5453. };
  5454. /** @hidden */
  5455. Control.drawEllipse = function (x, y, width, height, context) {
  5456. context.translate(x, y);
  5457. context.scale(width, height);
  5458. context.beginPath();
  5459. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5460. context.closePath();
  5461. context.scale(1 / width, 1 / height);
  5462. context.translate(-x, -y);
  5463. };
  5464. /**
  5465. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5466. */
  5467. Control.AllowAlphaInheritance = false;
  5468. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5469. // Statics
  5470. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5471. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5472. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5473. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5474. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5475. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5476. Control._FontHeightSizes = {};
  5477. /**
  5478. * Creates a stack panel that can be used to render headers
  5479. * @param control defines the control to associate with the header
  5480. * @param text defines the text of the header
  5481. * @param size defines the size of the header
  5482. * @param options defines options used to configure the header
  5483. * @returns a new StackPanel
  5484. * @ignore
  5485. * @hidden
  5486. */
  5487. Control.AddHeader = function () { };
  5488. return Control;
  5489. }());
  5490. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5491. /***/ }),
  5492. /***/ "./2D/controls/displayGrid.ts":
  5493. /*!************************************!*\
  5494. !*** ./2D/controls/displayGrid.ts ***!
  5495. \************************************/
  5496. /*! exports provided: DisplayGrid */
  5497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5498. "use strict";
  5499. __webpack_require__.r(__webpack_exports__);
  5500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5501. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5502. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5503. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5504. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5505. /** Class used to render a grid */
  5506. var DisplayGrid = /** @class */ (function (_super) {
  5507. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5508. /**
  5509. * Creates a new GridDisplayRectangle
  5510. * @param name defines the control name
  5511. */
  5512. function DisplayGrid(name) {
  5513. var _this = _super.call(this, name) || this;
  5514. _this.name = name;
  5515. _this._cellWidth = 20;
  5516. _this._cellHeight = 20;
  5517. _this._minorLineTickness = 1;
  5518. _this._minorLineColor = "DarkGray";
  5519. _this._majorLineTickness = 2;
  5520. _this._majorLineColor = "White";
  5521. _this._majorLineFrequency = 5;
  5522. _this._background = "Black";
  5523. _this._displayMajorLines = true;
  5524. _this._displayMinorLines = true;
  5525. return _this;
  5526. }
  5527. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5528. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5529. get: function () {
  5530. return this._displayMinorLines;
  5531. },
  5532. set: function (value) {
  5533. if (this._displayMinorLines === value) {
  5534. return;
  5535. }
  5536. this._displayMinorLines = value;
  5537. this._markAsDirty();
  5538. },
  5539. enumerable: true,
  5540. configurable: true
  5541. });
  5542. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5543. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5544. get: function () {
  5545. return this._displayMajorLines;
  5546. },
  5547. set: function (value) {
  5548. if (this._displayMajorLines === value) {
  5549. return;
  5550. }
  5551. this._displayMajorLines = value;
  5552. this._markAsDirty();
  5553. },
  5554. enumerable: true,
  5555. configurable: true
  5556. });
  5557. Object.defineProperty(DisplayGrid.prototype, "background", {
  5558. /** Gets or sets background color (Black by default) */
  5559. get: function () {
  5560. return this._background;
  5561. },
  5562. set: function (value) {
  5563. if (this._background === value) {
  5564. return;
  5565. }
  5566. this._background = value;
  5567. this._markAsDirty();
  5568. },
  5569. enumerable: true,
  5570. configurable: true
  5571. });
  5572. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5573. /** Gets or sets the width of each cell (20 by default) */
  5574. get: function () {
  5575. return this._cellWidth;
  5576. },
  5577. set: function (value) {
  5578. this._cellWidth = value;
  5579. this._markAsDirty();
  5580. },
  5581. enumerable: true,
  5582. configurable: true
  5583. });
  5584. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5585. /** Gets or sets the height of each cell (20 by default) */
  5586. get: function () {
  5587. return this._cellHeight;
  5588. },
  5589. set: function (value) {
  5590. this._cellHeight = value;
  5591. this._markAsDirty();
  5592. },
  5593. enumerable: true,
  5594. configurable: true
  5595. });
  5596. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5597. /** Gets or sets the tickness of minor lines (1 by default) */
  5598. get: function () {
  5599. return this._minorLineTickness;
  5600. },
  5601. set: function (value) {
  5602. this._minorLineTickness = value;
  5603. this._markAsDirty();
  5604. },
  5605. enumerable: true,
  5606. configurable: true
  5607. });
  5608. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5609. /** Gets or sets the color of minor lines (DarkGray by default) */
  5610. get: function () {
  5611. return this._minorLineColor;
  5612. },
  5613. set: function (value) {
  5614. this._minorLineColor = value;
  5615. this._markAsDirty();
  5616. },
  5617. enumerable: true,
  5618. configurable: true
  5619. });
  5620. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5621. /** Gets or sets the tickness of major lines (2 by default) */
  5622. get: function () {
  5623. return this._majorLineTickness;
  5624. },
  5625. set: function (value) {
  5626. this._majorLineTickness = value;
  5627. this._markAsDirty();
  5628. },
  5629. enumerable: true,
  5630. configurable: true
  5631. });
  5632. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5633. /** Gets or sets the color of major lines (White by default) */
  5634. get: function () {
  5635. return this._majorLineColor;
  5636. },
  5637. set: function (value) {
  5638. this._majorLineColor = value;
  5639. this._markAsDirty();
  5640. },
  5641. enumerable: true,
  5642. configurable: true
  5643. });
  5644. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5645. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5646. get: function () {
  5647. return this._majorLineFrequency;
  5648. },
  5649. set: function (value) {
  5650. this._majorLineFrequency = value;
  5651. this._markAsDirty();
  5652. },
  5653. enumerable: true,
  5654. configurable: true
  5655. });
  5656. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5657. context.save();
  5658. this._applyStates(context);
  5659. if (this._isEnabled) {
  5660. if (this._background) {
  5661. context.fillStyle = this._background;
  5662. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5663. }
  5664. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5665. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5666. // Minor lines
  5667. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5668. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5669. if (this._displayMinorLines) {
  5670. context.strokeStyle = this._minorLineColor;
  5671. context.lineWidth = this._minorLineTickness;
  5672. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5673. var cellX = left + x * this.cellWidth;
  5674. context.beginPath();
  5675. context.moveTo(cellX, this._currentMeasure.top);
  5676. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5677. context.stroke();
  5678. }
  5679. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5680. var cellY = top_1 + y * this.cellHeight;
  5681. context.beginPath();
  5682. context.moveTo(this._currentMeasure.left, cellY);
  5683. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5684. context.stroke();
  5685. }
  5686. }
  5687. // Major lines
  5688. if (this._displayMajorLines) {
  5689. context.strokeStyle = this._majorLineColor;
  5690. context.lineWidth = this._majorLineTickness;
  5691. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5692. var cellX = left + x * this.cellWidth;
  5693. context.beginPath();
  5694. context.moveTo(cellX, this._currentMeasure.top);
  5695. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5696. context.stroke();
  5697. }
  5698. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5699. var cellY = top_1 + y * this.cellHeight;
  5700. context.moveTo(this._currentMeasure.left, cellY);
  5701. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5702. context.closePath();
  5703. context.stroke();
  5704. }
  5705. }
  5706. }
  5707. context.restore();
  5708. };
  5709. DisplayGrid.prototype._getTypeName = function () {
  5710. return "DisplayGrid";
  5711. };
  5712. return DisplayGrid;
  5713. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5714. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5715. /***/ }),
  5716. /***/ "./2D/controls/ellipse.ts":
  5717. /*!********************************!*\
  5718. !*** ./2D/controls/ellipse.ts ***!
  5719. \********************************/
  5720. /*! exports provided: Ellipse */
  5721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5722. "use strict";
  5723. __webpack_require__.r(__webpack_exports__);
  5724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5726. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5727. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5728. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5729. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5730. /** Class used to create 2D ellipse containers */
  5731. var Ellipse = /** @class */ (function (_super) {
  5732. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5733. /**
  5734. * Creates a new Ellipse
  5735. * @param name defines the control name
  5736. */
  5737. function Ellipse(name) {
  5738. var _this = _super.call(this, name) || this;
  5739. _this.name = name;
  5740. _this._thickness = 1;
  5741. return _this;
  5742. }
  5743. Object.defineProperty(Ellipse.prototype, "thickness", {
  5744. /** Gets or sets border thickness */
  5745. get: function () {
  5746. return this._thickness;
  5747. },
  5748. set: function (value) {
  5749. if (this._thickness === value) {
  5750. return;
  5751. }
  5752. this._thickness = value;
  5753. this._markAsDirty();
  5754. },
  5755. enumerable: true,
  5756. configurable: true
  5757. });
  5758. Ellipse.prototype._getTypeName = function () {
  5759. return "Ellipse";
  5760. };
  5761. Ellipse.prototype._localDraw = function (context) {
  5762. context.save();
  5763. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5764. context.shadowColor = this.shadowColor;
  5765. context.shadowBlur = this.shadowBlur;
  5766. context.shadowOffsetX = this.shadowOffsetX;
  5767. context.shadowOffsetY = this.shadowOffsetY;
  5768. }
  5769. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5770. if (this._background) {
  5771. context.fillStyle = this._background;
  5772. context.fill();
  5773. }
  5774. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5775. context.shadowBlur = 0;
  5776. context.shadowOffsetX = 0;
  5777. context.shadowOffsetY = 0;
  5778. }
  5779. if (this._thickness) {
  5780. if (this.color) {
  5781. context.strokeStyle = this.color;
  5782. }
  5783. context.lineWidth = this._thickness;
  5784. context.stroke();
  5785. }
  5786. context.restore();
  5787. };
  5788. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5789. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5790. this._measureForChildren.width -= 2 * this._thickness;
  5791. this._measureForChildren.height -= 2 * this._thickness;
  5792. this._measureForChildren.left += this._thickness;
  5793. this._measureForChildren.top += this._thickness;
  5794. };
  5795. Ellipse.prototype._clipForChildren = function (context) {
  5796. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5797. context.clip();
  5798. };
  5799. return Ellipse;
  5800. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5801. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5802. /***/ }),
  5803. /***/ "./2D/controls/grid.ts":
  5804. /*!*****************************!*\
  5805. !*** ./2D/controls/grid.ts ***!
  5806. \*****************************/
  5807. /*! exports provided: Grid */
  5808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5809. "use strict";
  5810. __webpack_require__.r(__webpack_exports__);
  5811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5812. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5813. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5814. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5815. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5816. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  5817. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5818. /**
  5819. * Class used to create a 2D grid container
  5820. */
  5821. var Grid = /** @class */ (function (_super) {
  5822. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5823. /**
  5824. * Creates a new Grid
  5825. * @param name defines control name
  5826. */
  5827. function Grid(name) {
  5828. var _this = _super.call(this, name) || this;
  5829. _this.name = name;
  5830. _this._rowDefinitions = new Array();
  5831. _this._columnDefinitions = new Array();
  5832. _this._cells = {};
  5833. _this._childControls = new Array();
  5834. return _this;
  5835. }
  5836. Object.defineProperty(Grid.prototype, "columnCount", {
  5837. /**
  5838. * Gets the number of columns
  5839. */
  5840. get: function () {
  5841. return this._columnDefinitions.length;
  5842. },
  5843. enumerable: true,
  5844. configurable: true
  5845. });
  5846. Object.defineProperty(Grid.prototype, "rowCount", {
  5847. /**
  5848. * Gets the number of rows
  5849. */
  5850. get: function () {
  5851. return this._rowDefinitions.length;
  5852. },
  5853. enumerable: true,
  5854. configurable: true
  5855. });
  5856. Object.defineProperty(Grid.prototype, "children", {
  5857. /** Gets the list of children */
  5858. get: function () {
  5859. return this._childControls;
  5860. },
  5861. enumerable: true,
  5862. configurable: true
  5863. });
  5864. Object.defineProperty(Grid.prototype, "cells", {
  5865. /** Gets the list of cells (e.g. the containers) */
  5866. get: function () {
  5867. return this._cells;
  5868. },
  5869. enumerable: true,
  5870. configurable: true
  5871. });
  5872. /**
  5873. * Gets the definition of a specific row
  5874. * @param index defines the index of the row
  5875. * @returns the row definition
  5876. */
  5877. Grid.prototype.getRowDefinition = function (index) {
  5878. if (index < 0 || index >= this._rowDefinitions.length) {
  5879. return null;
  5880. }
  5881. return this._rowDefinitions[index];
  5882. };
  5883. /**
  5884. * Gets the definition of a specific column
  5885. * @param index defines the index of the column
  5886. * @returns the column definition
  5887. */
  5888. Grid.prototype.getColumnDefinition = function (index) {
  5889. if (index < 0 || index >= this._columnDefinitions.length) {
  5890. return null;
  5891. }
  5892. return this._columnDefinitions[index];
  5893. };
  5894. /**
  5895. * Adds a new row to the grid
  5896. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5897. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5898. * @returns the current grid
  5899. */
  5900. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5901. if (isPixel === void 0) { isPixel = false; }
  5902. this._rowDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5903. this._markAsDirty();
  5904. return this;
  5905. };
  5906. /**
  5907. * Adds a new column to the grid
  5908. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5909. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5910. * @returns the current grid
  5911. */
  5912. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5913. if (isPixel === void 0) { isPixel = false; }
  5914. this._columnDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5915. this._markAsDirty();
  5916. return this;
  5917. };
  5918. /**
  5919. * Update a row definition
  5920. * @param index defines the index of the row to update
  5921. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5922. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5923. * @returns the current grid
  5924. */
  5925. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5926. if (isPixel === void 0) { isPixel = false; }
  5927. if (index < 0 || index >= this._rowDefinitions.length) {
  5928. return this;
  5929. }
  5930. var current = this._rowDefinitions[index];
  5931. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5932. return this;
  5933. }
  5934. this._rowDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5935. this._markAsDirty();
  5936. return this;
  5937. };
  5938. /**
  5939. * Update a column definition
  5940. * @param index defines the index of the column to update
  5941. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5942. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5943. * @returns the current grid
  5944. */
  5945. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5946. if (isPixel === void 0) { isPixel = false; }
  5947. if (index < 0 || index >= this._columnDefinitions.length) {
  5948. return this;
  5949. }
  5950. var current = this._columnDefinitions[index];
  5951. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5952. return this;
  5953. }
  5954. this._columnDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5955. this._markAsDirty();
  5956. return this;
  5957. };
  5958. /**
  5959. * Gets the list of children stored in a specific cell
  5960. * @param row defines the row to check
  5961. * @param column defines the column to check
  5962. * @returns the list of controls
  5963. */
  5964. Grid.prototype.getChildrenAt = function (row, column) {
  5965. var cell = this._cells[row + ":" + column];
  5966. if (!cell) {
  5967. return null;
  5968. }
  5969. return cell.children;
  5970. };
  5971. /**
  5972. * Gets a string representing the child cell info (row x column)
  5973. * @param child defines the control to get info from
  5974. * @returns a string containing the child cell info (row x column)
  5975. */
  5976. Grid.prototype.getChildCellInfo = function (child) {
  5977. return child._tag;
  5978. };
  5979. Grid.prototype._removeCell = function (cell, key) {
  5980. if (!cell) {
  5981. return;
  5982. }
  5983. _super.prototype.removeControl.call(this, cell);
  5984. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5985. var control = _a[_i];
  5986. var childIndex = this._childControls.indexOf(control);
  5987. if (childIndex !== -1) {
  5988. this._childControls.splice(childIndex, 1);
  5989. }
  5990. }
  5991. delete this._cells[key];
  5992. };
  5993. Grid.prototype._offsetCell = function (previousKey, key) {
  5994. if (!this._cells[key]) {
  5995. return;
  5996. }
  5997. this._cells[previousKey] = this._cells[key];
  5998. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5999. var control = _a[_i];
  6000. control._tag = previousKey;
  6001. }
  6002. delete this._cells[key];
  6003. };
  6004. /**
  6005. * Remove a column definition at specified index
  6006. * @param index defines the index of the column to remove
  6007. * @returns the current grid
  6008. */
  6009. Grid.prototype.removeColumnDefinition = function (index) {
  6010. if (index < 0 || index >= this._columnDefinitions.length) {
  6011. return this;
  6012. }
  6013. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6014. var key = x + ":" + index;
  6015. var cell = this._cells[key];
  6016. this._removeCell(cell, key);
  6017. }
  6018. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6019. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6020. var previousKey = x + ":" + (y - 1);
  6021. var key = x + ":" + y;
  6022. this._offsetCell(previousKey, key);
  6023. }
  6024. }
  6025. this._columnDefinitions.splice(index, 1);
  6026. this._markAsDirty();
  6027. return this;
  6028. };
  6029. /**
  6030. * Remove a row definition at specified index
  6031. * @param index defines the index of the row to remove
  6032. * @returns the current grid
  6033. */
  6034. Grid.prototype.removeRowDefinition = function (index) {
  6035. if (index < 0 || index >= this._rowDefinitions.length) {
  6036. return this;
  6037. }
  6038. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6039. var key = index + ":" + y;
  6040. var cell = this._cells[key];
  6041. this._removeCell(cell, key);
  6042. }
  6043. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6044. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6045. var previousKey = x - 1 + ":" + y;
  6046. var key = x + ":" + y;
  6047. this._offsetCell(previousKey, key);
  6048. }
  6049. }
  6050. this._rowDefinitions.splice(index, 1);
  6051. this._markAsDirty();
  6052. return this;
  6053. };
  6054. /**
  6055. * Adds a new control to the current grid
  6056. * @param control defines the control to add
  6057. * @param row defines the row where to add the control (0 by default)
  6058. * @param column defines the column where to add the control (0 by default)
  6059. * @returns the current grid
  6060. */
  6061. Grid.prototype.addControl = function (control, row, column) {
  6062. if (row === void 0) { row = 0; }
  6063. if (column === void 0) { column = 0; }
  6064. if (this._rowDefinitions.length === 0) {
  6065. // Add default row definition
  6066. this.addRowDefinition(1, false);
  6067. }
  6068. if (this._columnDefinitions.length === 0) {
  6069. // Add default column definition
  6070. this.addColumnDefinition(1, false);
  6071. }
  6072. if (this._childControls.indexOf(control) !== -1) {
  6073. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  6074. return this;
  6075. }
  6076. var x = Math.min(row, this._rowDefinitions.length - 1);
  6077. var y = Math.min(column, this._columnDefinitions.length - 1);
  6078. var key = x + ":" + y;
  6079. var goodContainer = this._cells[key];
  6080. if (!goodContainer) {
  6081. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6082. this._cells[key] = goodContainer;
  6083. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6084. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6085. _super.prototype.addControl.call(this, goodContainer);
  6086. }
  6087. goodContainer.addControl(control);
  6088. this._childControls.push(control);
  6089. control._tag = key;
  6090. control.parent = this;
  6091. this._markAsDirty();
  6092. return this;
  6093. };
  6094. /**
  6095. * Removes a control from the current container
  6096. * @param control defines the control to remove
  6097. * @returns the current container
  6098. */
  6099. Grid.prototype.removeControl = function (control) {
  6100. var index = this._childControls.indexOf(control);
  6101. if (index !== -1) {
  6102. this._childControls.splice(index, 1);
  6103. }
  6104. var cell = this._cells[control._tag];
  6105. if (cell) {
  6106. cell.removeControl(control);
  6107. control._tag = null;
  6108. }
  6109. this._markAsDirty();
  6110. return this;
  6111. };
  6112. Grid.prototype._getTypeName = function () {
  6113. return "Grid";
  6114. };
  6115. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6116. var widths = [];
  6117. var heights = [];
  6118. var lefts = [];
  6119. var tops = [];
  6120. var availableWidth = this._currentMeasure.width;
  6121. var globalWidthPercentage = 0;
  6122. var availableHeight = this._currentMeasure.height;
  6123. var globalHeightPercentage = 0;
  6124. // Heights
  6125. var index = 0;
  6126. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6127. var value = _a[_i];
  6128. if (value.isPixel) {
  6129. var height = value.getValue(this._host);
  6130. availableHeight -= height;
  6131. heights[index] = height;
  6132. }
  6133. else {
  6134. globalHeightPercentage += value.internalValue;
  6135. }
  6136. index++;
  6137. }
  6138. var top = 0;
  6139. index = 0;
  6140. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6141. var value = _c[_b];
  6142. tops.push(top);
  6143. if (!value.isPixel) {
  6144. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6145. top += height;
  6146. heights[index] = height;
  6147. }
  6148. else {
  6149. top += value.getValue(this._host);
  6150. }
  6151. index++;
  6152. }
  6153. // Widths
  6154. index = 0;
  6155. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6156. var value = _e[_d];
  6157. if (value.isPixel) {
  6158. var width = value.getValue(this._host);
  6159. availableWidth -= width;
  6160. widths[index] = width;
  6161. }
  6162. else {
  6163. globalWidthPercentage += value.internalValue;
  6164. }
  6165. index++;
  6166. }
  6167. var left = 0;
  6168. index = 0;
  6169. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6170. var value = _g[_f];
  6171. lefts.push(left);
  6172. if (!value.isPixel) {
  6173. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6174. left += width;
  6175. widths[index] = width;
  6176. }
  6177. else {
  6178. left += value.getValue(this._host);
  6179. }
  6180. index++;
  6181. }
  6182. definitionCallback(lefts, tops, widths, heights);
  6183. };
  6184. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6185. var _this = this;
  6186. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6187. // Setting child sizes
  6188. for (var key in _this._cells) {
  6189. if (!_this._cells.hasOwnProperty(key)) {
  6190. continue;
  6191. }
  6192. var split = key.split(":");
  6193. var x = parseInt(split[0]);
  6194. var y = parseInt(split[1]);
  6195. var cell = _this._cells[key];
  6196. cell.left = lefts[y] + "px";
  6197. cell.top = tops[x] + "px";
  6198. cell.width = widths[y] + "px";
  6199. cell.height = heights[x] + "px";
  6200. cell._left.ignoreAdaptiveScaling = true;
  6201. cell._top.ignoreAdaptiveScaling = true;
  6202. cell._width.ignoreAdaptiveScaling = true;
  6203. cell._height.ignoreAdaptiveScaling = true;
  6204. }
  6205. });
  6206. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6207. };
  6208. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6209. for (var key in this._cells) {
  6210. if (!this._cells.hasOwnProperty(key)) {
  6211. continue;
  6212. }
  6213. var child = this._cells[key];
  6214. child._markMatrixAsDirty();
  6215. }
  6216. };
  6217. Grid.prototype._renderHighlightSpecific = function (context) {
  6218. var _this = this;
  6219. _super.prototype._renderHighlightSpecific.call(this, context);
  6220. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6221. // Columns
  6222. for (var index = 0; index < lefts.length; index++) {
  6223. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6224. context.beginPath();
  6225. context.moveTo(left, _this._currentMeasure.top);
  6226. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6227. context.stroke();
  6228. }
  6229. // Rows
  6230. for (var index = 0; index < tops.length; index++) {
  6231. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6232. context.beginPath();
  6233. context.moveTo(_this._currentMeasure.left, top_1);
  6234. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6235. context.stroke();
  6236. }
  6237. });
  6238. context.restore();
  6239. };
  6240. /** Releases associated resources */
  6241. Grid.prototype.dispose = function () {
  6242. _super.prototype.dispose.call(this);
  6243. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6244. var control = _a[_i];
  6245. control.dispose();
  6246. }
  6247. this._childControls = [];
  6248. };
  6249. return Grid;
  6250. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6251. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6252. /***/ }),
  6253. /***/ "./2D/controls/image.ts":
  6254. /*!******************************!*\
  6255. !*** ./2D/controls/image.ts ***!
  6256. \******************************/
  6257. /*! exports provided: Image */
  6258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6259. "use strict";
  6260. __webpack_require__.r(__webpack_exports__);
  6261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6262. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6263. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  6264. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6265. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6266. /**
  6267. * Class used to create 2D images
  6268. */
  6269. var Image = /** @class */ (function (_super) {
  6270. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6271. /**
  6272. * Creates a new Image
  6273. * @param name defines the control name
  6274. * @param url defines the image url
  6275. */
  6276. function Image(name, url) {
  6277. if (url === void 0) { url = null; }
  6278. var _this = _super.call(this, name) || this;
  6279. _this.name = name;
  6280. _this._workingCanvas = null;
  6281. _this._loaded = false;
  6282. _this._stretch = Image.STRETCH_FILL;
  6283. _this._autoScale = false;
  6284. _this._sourceLeft = 0;
  6285. _this._sourceTop = 0;
  6286. _this._sourceWidth = 0;
  6287. _this._sourceHeight = 0;
  6288. _this._svgAttributesComputationCompleted = false;
  6289. _this._isSVG = false;
  6290. _this._cellWidth = 0;
  6291. _this._cellHeight = 0;
  6292. _this._cellId = -1;
  6293. _this._populateNinePatchSlicesFromImage = false;
  6294. /**
  6295. * Observable notified when the content is loaded
  6296. */
  6297. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6298. /**
  6299. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6300. */
  6301. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6302. _this.source = url;
  6303. return _this;
  6304. }
  6305. Object.defineProperty(Image.prototype, "isLoaded", {
  6306. /**
  6307. * Gets a boolean indicating that the content is loaded
  6308. */
  6309. get: function () {
  6310. return this._loaded;
  6311. },
  6312. enumerable: true,
  6313. configurable: true
  6314. });
  6315. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6316. /**
  6317. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6318. */
  6319. get: function () {
  6320. return this._populateNinePatchSlicesFromImage;
  6321. },
  6322. set: function (value) {
  6323. if (this._populateNinePatchSlicesFromImage === value) {
  6324. return;
  6325. }
  6326. this._populateNinePatchSlicesFromImage = value;
  6327. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6328. this._extractNinePatchSliceDataFromImage();
  6329. }
  6330. },
  6331. enumerable: true,
  6332. configurable: true
  6333. });
  6334. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6335. /**
  6336. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6337. * Beware using this as this will comsume more memory as the image has to be stored twice
  6338. */
  6339. get: function () {
  6340. return this._detectPointerOnOpaqueOnly;
  6341. },
  6342. set: function (value) {
  6343. if (this._detectPointerOnOpaqueOnly === value) {
  6344. return;
  6345. }
  6346. this._detectPointerOnOpaqueOnly = value;
  6347. },
  6348. enumerable: true,
  6349. configurable: true
  6350. });
  6351. Object.defineProperty(Image.prototype, "sliceLeft", {
  6352. /**
  6353. * Gets or sets the left value for slicing (9-patch)
  6354. */
  6355. get: function () {
  6356. return this._sliceLeft;
  6357. },
  6358. set: function (value) {
  6359. if (this._sliceLeft === value) {
  6360. return;
  6361. }
  6362. this._sliceLeft = value;
  6363. this._markAsDirty();
  6364. },
  6365. enumerable: true,
  6366. configurable: true
  6367. });
  6368. Object.defineProperty(Image.prototype, "sliceRight", {
  6369. /**
  6370. * Gets or sets the right value for slicing (9-patch)
  6371. */
  6372. get: function () {
  6373. return this._sliceRight;
  6374. },
  6375. set: function (value) {
  6376. if (this._sliceRight === value) {
  6377. return;
  6378. }
  6379. this._sliceRight = value;
  6380. this._markAsDirty();
  6381. },
  6382. enumerable: true,
  6383. configurable: true
  6384. });
  6385. Object.defineProperty(Image.prototype, "sliceTop", {
  6386. /**
  6387. * Gets or sets the top value for slicing (9-patch)
  6388. */
  6389. get: function () {
  6390. return this._sliceTop;
  6391. },
  6392. set: function (value) {
  6393. if (this._sliceTop === value) {
  6394. return;
  6395. }
  6396. this._sliceTop = value;
  6397. this._markAsDirty();
  6398. },
  6399. enumerable: true,
  6400. configurable: true
  6401. });
  6402. Object.defineProperty(Image.prototype, "sliceBottom", {
  6403. /**
  6404. * Gets or sets the bottom value for slicing (9-patch)
  6405. */
  6406. get: function () {
  6407. return this._sliceBottom;
  6408. },
  6409. set: function (value) {
  6410. if (this._sliceBottom === value) {
  6411. return;
  6412. }
  6413. this._sliceBottom = value;
  6414. this._markAsDirty();
  6415. },
  6416. enumerable: true,
  6417. configurable: true
  6418. });
  6419. Object.defineProperty(Image.prototype, "sourceLeft", {
  6420. /**
  6421. * Gets or sets the left coordinate in the source image
  6422. */
  6423. get: function () {
  6424. return this._sourceLeft;
  6425. },
  6426. set: function (value) {
  6427. if (this._sourceLeft === value) {
  6428. return;
  6429. }
  6430. this._sourceLeft = value;
  6431. this._markAsDirty();
  6432. },
  6433. enumerable: true,
  6434. configurable: true
  6435. });
  6436. Object.defineProperty(Image.prototype, "sourceTop", {
  6437. /**
  6438. * Gets or sets the top coordinate in the source image
  6439. */
  6440. get: function () {
  6441. return this._sourceTop;
  6442. },
  6443. set: function (value) {
  6444. if (this._sourceTop === value) {
  6445. return;
  6446. }
  6447. this._sourceTop = value;
  6448. this._markAsDirty();
  6449. },
  6450. enumerable: true,
  6451. configurable: true
  6452. });
  6453. Object.defineProperty(Image.prototype, "sourceWidth", {
  6454. /**
  6455. * Gets or sets the width to capture in the source image
  6456. */
  6457. get: function () {
  6458. return this._sourceWidth;
  6459. },
  6460. set: function (value) {
  6461. if (this._sourceWidth === value) {
  6462. return;
  6463. }
  6464. this._sourceWidth = value;
  6465. this._markAsDirty();
  6466. },
  6467. enumerable: true,
  6468. configurable: true
  6469. });
  6470. Object.defineProperty(Image.prototype, "sourceHeight", {
  6471. /**
  6472. * Gets or sets the height to capture in the source image
  6473. */
  6474. get: function () {
  6475. return this._sourceHeight;
  6476. },
  6477. set: function (value) {
  6478. if (this._sourceHeight === value) {
  6479. return;
  6480. }
  6481. this._sourceHeight = value;
  6482. this._markAsDirty();
  6483. },
  6484. enumerable: true,
  6485. configurable: true
  6486. });
  6487. Object.defineProperty(Image.prototype, "isSVG", {
  6488. /** Indicates if the format of the image is SVG */
  6489. get: function () {
  6490. return this._isSVG;
  6491. },
  6492. enumerable: true,
  6493. configurable: true
  6494. });
  6495. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6496. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6497. get: function () {
  6498. return this._svgAttributesComputationCompleted;
  6499. },
  6500. enumerable: true,
  6501. configurable: true
  6502. });
  6503. Object.defineProperty(Image.prototype, "autoScale", {
  6504. /**
  6505. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6506. * @see http://doc.babylonjs.com/how_to/gui#image
  6507. */
  6508. get: function () {
  6509. return this._autoScale;
  6510. },
  6511. set: function (value) {
  6512. if (this._autoScale === value) {
  6513. return;
  6514. }
  6515. this._autoScale = value;
  6516. if (value && this._loaded) {
  6517. this.synchronizeSizeWithContent();
  6518. }
  6519. },
  6520. enumerable: true,
  6521. configurable: true
  6522. });
  6523. Object.defineProperty(Image.prototype, "stretch", {
  6524. /** Gets or sets the streching mode used by the image */
  6525. get: function () {
  6526. return this._stretch;
  6527. },
  6528. set: function (value) {
  6529. if (this._stretch === value) {
  6530. return;
  6531. }
  6532. this._stretch = value;
  6533. this._markAsDirty();
  6534. },
  6535. enumerable: true,
  6536. configurable: true
  6537. });
  6538. /** @hidden */
  6539. Image.prototype._rotate90 = function (n, preserveProperties) {
  6540. if (preserveProperties === void 0) { preserveProperties = false; }
  6541. var canvas = document.createElement('canvas');
  6542. var context = canvas.getContext('2d');
  6543. var width = this._domImage.width;
  6544. var height = this._domImage.height;
  6545. canvas.width = height;
  6546. canvas.height = width;
  6547. context.translate(canvas.width / 2, canvas.height / 2);
  6548. context.rotate(n * Math.PI / 2);
  6549. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6550. var dataUrl = canvas.toDataURL("image/jpg");
  6551. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6552. if (preserveProperties) {
  6553. rotatedImage._stretch = this._stretch;
  6554. rotatedImage._autoScale = this._autoScale;
  6555. rotatedImage._cellId = this._cellId;
  6556. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6557. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6558. }
  6559. this._handleRotationForSVGImage(this, rotatedImage, n);
  6560. return rotatedImage;
  6561. };
  6562. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6563. var _this = this;
  6564. if (!srcImage._isSVG) {
  6565. return;
  6566. }
  6567. if (srcImage._svgAttributesComputationCompleted) {
  6568. this._rotate90SourceProperties(srcImage, dstImage, n);
  6569. this._markAsDirty();
  6570. }
  6571. else {
  6572. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6573. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6574. _this._markAsDirty();
  6575. });
  6576. }
  6577. };
  6578. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6579. var _a, _b;
  6580. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6581. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6582. if (n != 0) {
  6583. var mult = n < 0 ? -1 : 1;
  6584. n = n % 4;
  6585. for (var i = 0; i < Math.abs(n); ++i) {
  6586. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6587. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6588. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6589. if (n < 0) {
  6590. dstTop -= dstHeight;
  6591. }
  6592. else {
  6593. dstLeft -= dstWidth;
  6594. }
  6595. srcLeft = dstLeft;
  6596. srcTop = dstTop;
  6597. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6598. }
  6599. }
  6600. dstImage.sourceLeft = dstLeft;
  6601. dstImage.sourceTop = dstTop;
  6602. dstImage.sourceWidth = dstWidth;
  6603. dstImage.sourceHeight = dstHeight;
  6604. };
  6605. Object.defineProperty(Image.prototype, "domImage", {
  6606. get: function () {
  6607. return this._domImage;
  6608. },
  6609. /**
  6610. * Gets or sets the internal DOM image used to render the control
  6611. */
  6612. set: function (value) {
  6613. var _this = this;
  6614. this._domImage = value;
  6615. this._loaded = false;
  6616. if (this._domImage.width) {
  6617. this._onImageLoaded();
  6618. }
  6619. else {
  6620. this._domImage.onload = function () {
  6621. _this._onImageLoaded();
  6622. };
  6623. }
  6624. },
  6625. enumerable: true,
  6626. configurable: true
  6627. });
  6628. Image.prototype._onImageLoaded = function () {
  6629. this._imageWidth = this._domImage.width;
  6630. this._imageHeight = this._domImage.height;
  6631. this._loaded = true;
  6632. if (this._populateNinePatchSlicesFromImage) {
  6633. this._extractNinePatchSliceDataFromImage();
  6634. }
  6635. if (this._autoScale) {
  6636. this.synchronizeSizeWithContent();
  6637. }
  6638. this.onImageLoadedObservable.notifyObservers(this);
  6639. this._markAsDirty();
  6640. };
  6641. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6642. if (!this._workingCanvas) {
  6643. this._workingCanvas = document.createElement('canvas');
  6644. }
  6645. var canvas = this._workingCanvas;
  6646. var context = canvas.getContext('2d');
  6647. var width = this._domImage.width;
  6648. var height = this._domImage.height;
  6649. canvas.width = width;
  6650. canvas.height = height;
  6651. context.drawImage(this._domImage, 0, 0, width, height);
  6652. var imageData = context.getImageData(0, 0, width, height);
  6653. // Left and right
  6654. this._sliceLeft = -1;
  6655. this._sliceRight = -1;
  6656. for (var x = 0; x < width; x++) {
  6657. var alpha = imageData.data[x * 4 + 3];
  6658. if (alpha > 127 && this._sliceLeft === -1) {
  6659. this._sliceLeft = x;
  6660. continue;
  6661. }
  6662. if (alpha < 127 && this._sliceLeft > -1) {
  6663. this._sliceRight = x;
  6664. break;
  6665. }
  6666. }
  6667. // top and bottom
  6668. this._sliceTop = -1;
  6669. this._sliceBottom = -1;
  6670. for (var y = 0; y < height; y++) {
  6671. var alpha = imageData.data[y * width * 4 + 3];
  6672. if (alpha > 127 && this._sliceTop === -1) {
  6673. this._sliceTop = y;
  6674. continue;
  6675. }
  6676. if (alpha < 127 && this._sliceTop > -1) {
  6677. this._sliceBottom = y;
  6678. break;
  6679. }
  6680. }
  6681. };
  6682. Object.defineProperty(Image.prototype, "source", {
  6683. /**
  6684. * Gets or sets image source url
  6685. */
  6686. set: function (value) {
  6687. var _this = this;
  6688. if (this._source === value) {
  6689. return;
  6690. }
  6691. this._loaded = false;
  6692. this._source = value;
  6693. if (value) {
  6694. value = this._svgCheck(value);
  6695. }
  6696. this._domImage = document.createElement("img");
  6697. this._domImage.onload = function () {
  6698. _this._onImageLoaded();
  6699. };
  6700. if (value) {
  6701. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6702. this._domImage.src = value;
  6703. }
  6704. },
  6705. enumerable: true,
  6706. configurable: true
  6707. });
  6708. /**
  6709. * Checks for svg document with icon id present
  6710. */
  6711. Image.prototype._svgCheck = function (value) {
  6712. var _this = this;
  6713. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6714. this._isSVG = true;
  6715. var svgsrc = value.split('#')[0];
  6716. var elemid = value.split('#')[1];
  6717. // check if object alr exist in document
  6718. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6719. if (svgExist) {
  6720. var svgDoc = svgExist.contentDocument;
  6721. // get viewbox width and height, get svg document width and height in px
  6722. if (svgDoc && svgDoc.documentElement) {
  6723. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6724. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6725. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6726. var elem = svgDoc.getElementById(elemid);
  6727. if (elem && vb && docwidth && docheight) {
  6728. this._getSVGAttribs(svgExist, elemid);
  6729. return value;
  6730. }
  6731. }
  6732. // wait for object to load
  6733. svgExist.addEventListener("load", function () {
  6734. _this._getSVGAttribs(svgExist, elemid);
  6735. });
  6736. }
  6737. else {
  6738. // create document object
  6739. var svgImage = document.createElement("object");
  6740. svgImage.data = svgsrc;
  6741. svgImage.type = "image/svg+xml";
  6742. svgImage.width = "0%";
  6743. svgImage.height = "0%";
  6744. document.body.appendChild(svgImage);
  6745. // when the object has loaded, get the element attribs
  6746. svgImage.onload = function () {
  6747. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6748. if (svgobj) {
  6749. _this._getSVGAttribs(svgobj, elemid);
  6750. }
  6751. };
  6752. }
  6753. return svgsrc;
  6754. }
  6755. else {
  6756. return value;
  6757. }
  6758. };
  6759. /**
  6760. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6761. * given external svg file and icon id
  6762. */
  6763. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6764. var svgDoc = svgsrc.contentDocument;
  6765. // get viewbox width and height, get svg document width and height in px
  6766. if (svgDoc && svgDoc.documentElement) {
  6767. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6768. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6769. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6770. // get element bbox and matrix transform
  6771. var elem = svgDoc.getElementById(elemid);
  6772. if (vb && docwidth && docheight && elem) {
  6773. var vb_width = Number(vb.split(" ")[2]);
  6774. var vb_height = Number(vb.split(" ")[3]);
  6775. var elem_bbox = elem.getBBox();
  6776. var elem_matrix_a = 1;
  6777. var elem_matrix_d = 1;
  6778. var elem_matrix_e = 0;
  6779. var elem_matrix_f = 0;
  6780. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6781. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6782. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6783. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6784. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6785. }
  6786. // compute source coordinates and dimensions
  6787. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6788. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6789. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6790. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6791. this._svgAttributesComputationCompleted = true;
  6792. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6793. }
  6794. }
  6795. };
  6796. Object.defineProperty(Image.prototype, "cellWidth", {
  6797. /**
  6798. * Gets or sets the cell width to use when animation sheet is enabled
  6799. * @see http://doc.babylonjs.com/how_to/gui#image
  6800. */
  6801. get: function () {
  6802. return this._cellWidth;
  6803. },
  6804. set: function (value) {
  6805. if (this._cellWidth === value) {
  6806. return;
  6807. }
  6808. this._cellWidth = value;
  6809. this._markAsDirty();
  6810. },
  6811. enumerable: true,
  6812. configurable: true
  6813. });
  6814. Object.defineProperty(Image.prototype, "cellHeight", {
  6815. /**
  6816. * Gets or sets the cell height to use when animation sheet is enabled
  6817. * @see http://doc.babylonjs.com/how_to/gui#image
  6818. */
  6819. get: function () {
  6820. return this._cellHeight;
  6821. },
  6822. set: function (value) {
  6823. if (this._cellHeight === value) {
  6824. return;
  6825. }
  6826. this._cellHeight = value;
  6827. this._markAsDirty();
  6828. },
  6829. enumerable: true,
  6830. configurable: true
  6831. });
  6832. Object.defineProperty(Image.prototype, "cellId", {
  6833. /**
  6834. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6835. * @see http://doc.babylonjs.com/how_to/gui#image
  6836. */
  6837. get: function () {
  6838. return this._cellId;
  6839. },
  6840. set: function (value) {
  6841. if (this._cellId === value) {
  6842. return;
  6843. }
  6844. this._cellId = value;
  6845. this._markAsDirty();
  6846. },
  6847. enumerable: true,
  6848. configurable: true
  6849. });
  6850. /**
  6851. * Tests if a given coordinates belong to the current control
  6852. * @param x defines x coordinate to test
  6853. * @param y defines y coordinate to test
  6854. * @returns true if the coordinates are inside the control
  6855. */
  6856. Image.prototype.contains = function (x, y) {
  6857. if (!_super.prototype.contains.call(this, x, y)) {
  6858. return false;
  6859. }
  6860. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6861. return true;
  6862. }
  6863. var canvas = this._workingCanvas;
  6864. var context = canvas.getContext("2d");
  6865. var width = this._currentMeasure.width | 0;
  6866. var height = this._currentMeasure.height | 0;
  6867. var imageData = context.getImageData(0, 0, width, height).data;
  6868. x = (x - this._currentMeasure.left) | 0;
  6869. y = (y - this._currentMeasure.top) | 0;
  6870. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6871. return pickedPixel > 0;
  6872. };
  6873. Image.prototype._getTypeName = function () {
  6874. return "Image";
  6875. };
  6876. /** Force the control to synchronize with its content */
  6877. Image.prototype.synchronizeSizeWithContent = function () {
  6878. if (!this._loaded) {
  6879. return;
  6880. }
  6881. this.width = this._domImage.width + "px";
  6882. this.height = this._domImage.height + "px";
  6883. };
  6884. Image.prototype._processMeasures = function (parentMeasure, context) {
  6885. if (this._loaded) {
  6886. switch (this._stretch) {
  6887. case Image.STRETCH_NONE:
  6888. break;
  6889. case Image.STRETCH_FILL:
  6890. break;
  6891. case Image.STRETCH_UNIFORM:
  6892. break;
  6893. case Image.STRETCH_NINE_PATCH:
  6894. break;
  6895. case Image.STRETCH_EXTEND:
  6896. if (this._autoScale) {
  6897. this.synchronizeSizeWithContent();
  6898. }
  6899. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6900. this.parent.adaptWidthToChildren = true;
  6901. this.parent.adaptHeightToChildren = true;
  6902. }
  6903. break;
  6904. }
  6905. }
  6906. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6907. };
  6908. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6909. if (!this._detectPointerOnOpaqueOnly) {
  6910. return;
  6911. }
  6912. if (!this._workingCanvas) {
  6913. this._workingCanvas = document.createElement('canvas');
  6914. }
  6915. var canvas = this._workingCanvas;
  6916. var width = this._currentMeasure.width;
  6917. var height = this._currentMeasure.height;
  6918. var context = canvas.getContext("2d");
  6919. canvas.width = width;
  6920. canvas.height = height;
  6921. context.clearRect(0, 0, width, height);
  6922. };
  6923. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6924. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6925. if (!this._detectPointerOnOpaqueOnly) {
  6926. return;
  6927. }
  6928. var canvas = this._workingCanvas;
  6929. context = canvas.getContext("2d");
  6930. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6931. };
  6932. Image.prototype._draw = function (context) {
  6933. context.save();
  6934. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6935. context.shadowColor = this.shadowColor;
  6936. context.shadowBlur = this.shadowBlur;
  6937. context.shadowOffsetX = this.shadowOffsetX;
  6938. context.shadowOffsetY = this.shadowOffsetY;
  6939. }
  6940. var x, y, width, height;
  6941. if (this.cellId == -1) {
  6942. x = this._sourceLeft;
  6943. y = this._sourceTop;
  6944. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6945. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6946. }
  6947. else {
  6948. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6949. var column = (this.cellId / rowCount) >> 0;
  6950. var row = this.cellId % rowCount;
  6951. x = this.cellWidth * row;
  6952. y = this.cellHeight * column;
  6953. width = this.cellWidth;
  6954. height = this.cellHeight;
  6955. }
  6956. this._prepareWorkingCanvasForOpaqueDetection();
  6957. this._applyStates(context);
  6958. if (this._loaded) {
  6959. switch (this._stretch) {
  6960. case Image.STRETCH_NONE:
  6961. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6962. break;
  6963. case Image.STRETCH_FILL:
  6964. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6965. break;
  6966. case Image.STRETCH_UNIFORM:
  6967. var hRatio = this._currentMeasure.width / width;
  6968. var vRatio = this._currentMeasure.height / height;
  6969. var ratio = Math.min(hRatio, vRatio);
  6970. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6971. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6972. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6973. break;
  6974. case Image.STRETCH_EXTEND:
  6975. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6976. break;
  6977. case Image.STRETCH_NINE_PATCH:
  6978. this._renderNinePatch(context);
  6979. break;
  6980. }
  6981. }
  6982. context.restore();
  6983. };
  6984. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6985. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6986. };
  6987. Image.prototype._renderNinePatch = function (context) {
  6988. var height = this._imageHeight;
  6989. var leftWidth = this._sliceLeft;
  6990. var topHeight = this._sliceTop;
  6991. var bottomHeight = this._imageHeight - this._sliceBottom;
  6992. var rightWidth = this._imageWidth - this._sliceRight;
  6993. var left = 0;
  6994. var top = 0;
  6995. if (this._populateNinePatchSlicesFromImage) {
  6996. left = 1;
  6997. top = 1;
  6998. height -= 2;
  6999. leftWidth -= 1;
  7000. topHeight -= 1;
  7001. bottomHeight -= 1;
  7002. rightWidth -= 1;
  7003. }
  7004. var centerWidth = this._sliceRight - this._sliceLeft;
  7005. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7006. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7007. // Corners
  7008. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7009. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7010. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7011. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7012. // Center
  7013. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7014. // Borders
  7015. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7016. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7017. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7018. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7019. };
  7020. Image.prototype.dispose = function () {
  7021. _super.prototype.dispose.call(this);
  7022. this.onImageLoadedObservable.clear();
  7023. this.onSVGAttributesComputedObservable.clear();
  7024. };
  7025. // Static
  7026. /** STRETCH_NONE */
  7027. Image.STRETCH_NONE = 0;
  7028. /** STRETCH_FILL */
  7029. Image.STRETCH_FILL = 1;
  7030. /** STRETCH_UNIFORM */
  7031. Image.STRETCH_UNIFORM = 2;
  7032. /** STRETCH_EXTEND */
  7033. Image.STRETCH_EXTEND = 3;
  7034. /** NINE_PATCH */
  7035. Image.STRETCH_NINE_PATCH = 4;
  7036. return Image;
  7037. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7038. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7039. /***/ }),
  7040. /***/ "./2D/controls/index.ts":
  7041. /*!******************************!*\
  7042. !*** ./2D/controls/index.ts ***!
  7043. \******************************/
  7044. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7046. "use strict";
  7047. __webpack_require__.r(__webpack_exports__);
  7048. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7050. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7052. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7054. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7056. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7058. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7060. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7062. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7064. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7066. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7068. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7070. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7072. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7074. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7076. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7082. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7084. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7087. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7090. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7092. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7094. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7096. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7098. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7100. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7102. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7104. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7106. /***/ }),
  7107. /***/ "./2D/controls/inputPassword.ts":
  7108. /*!**************************************!*\
  7109. !*** ./2D/controls/inputPassword.ts ***!
  7110. \**************************************/
  7111. /*! exports provided: InputPassword */
  7112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7113. "use strict";
  7114. __webpack_require__.r(__webpack_exports__);
  7115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7116. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7117. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7118. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  7119. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7120. /**
  7121. * Class used to create a password control
  7122. */
  7123. var InputPassword = /** @class */ (function (_super) {
  7124. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7125. function InputPassword() {
  7126. return _super !== null && _super.apply(this, arguments) || this;
  7127. }
  7128. InputPassword.prototype._beforeRenderText = function (text) {
  7129. var txt = "";
  7130. for (var i = 0; i < text.length; i++) {
  7131. txt += "\u2022";
  7132. }
  7133. return txt;
  7134. };
  7135. return InputPassword;
  7136. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7137. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7138. /***/ }),
  7139. /***/ "./2D/controls/inputText.ts":
  7140. /*!**********************************!*\
  7141. !*** ./2D/controls/inputText.ts ***!
  7142. \**********************************/
  7143. /*! exports provided: InputText */
  7144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7145. "use strict";
  7146. __webpack_require__.r(__webpack_exports__);
  7147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7148. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7149. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  7150. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7151. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7152. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7153. /**
  7154. * Class used to create input text control
  7155. */
  7156. var InputText = /** @class */ (function (_super) {
  7157. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7158. /**
  7159. * Creates a new InputText
  7160. * @param name defines the control name
  7161. * @param text defines the text of the control
  7162. */
  7163. function InputText(name, text) {
  7164. if (text === void 0) { text = ""; }
  7165. var _this = _super.call(this, name) || this;
  7166. _this.name = name;
  7167. _this._text = "";
  7168. _this._placeholderText = "";
  7169. _this._background = "#222222";
  7170. _this._focusedBackground = "#000000";
  7171. _this._focusedColor = "white";
  7172. _this._placeholderColor = "gray";
  7173. _this._thickness = 1;
  7174. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7175. _this._autoStretchWidth = true;
  7176. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7177. _this._isFocused = false;
  7178. _this._blinkIsEven = false;
  7179. _this._cursorOffset = 0;
  7180. _this._deadKey = false;
  7181. _this._addKey = true;
  7182. _this._currentKey = "";
  7183. _this._isTextHighlightOn = false;
  7184. _this._textHighlightColor = "#d5e0ff";
  7185. _this._highligherOpacity = 0.4;
  7186. _this._highlightedText = "";
  7187. _this._startHighlightIndex = 0;
  7188. _this._endHighlightIndex = 0;
  7189. _this._cursorIndex = -1;
  7190. _this._onFocusSelectAll = false;
  7191. _this._isPointerDown = false;
  7192. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7193. _this.promptMessage = "Please enter text:";
  7194. /** Force disable prompt on mobile device */
  7195. _this.disableMobilePrompt = false;
  7196. /** Observable raised when the text changes */
  7197. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7198. /** Observable raised just before an entered character is to be added */
  7199. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7200. /** Observable raised when the control gets the focus */
  7201. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7202. /** Observable raised when the control loses the focus */
  7203. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7204. /**Observable raised when the text is highlighted */
  7205. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7206. /**Observable raised when copy event is triggered */
  7207. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7208. /** Observable raised when cut event is triggered */
  7209. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7210. /** Observable raised when paste event is triggered */
  7211. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7212. /** Observable raised when a key event was processed */
  7213. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7214. _this.text = text;
  7215. _this.isPointerBlocker = true;
  7216. return _this;
  7217. }
  7218. Object.defineProperty(InputText.prototype, "maxWidth", {
  7219. /** Gets or sets the maximum width allowed by the control */
  7220. get: function () {
  7221. return this._maxWidth.toString(this._host);
  7222. },
  7223. set: function (value) {
  7224. if (this._maxWidth.toString(this._host) === value) {
  7225. return;
  7226. }
  7227. if (this._maxWidth.fromString(value)) {
  7228. this._markAsDirty();
  7229. }
  7230. },
  7231. enumerable: true,
  7232. configurable: true
  7233. });
  7234. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7235. /** Gets the maximum width allowed by the control in pixels */
  7236. get: function () {
  7237. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7238. },
  7239. enumerable: true,
  7240. configurable: true
  7241. });
  7242. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7243. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7244. get: function () {
  7245. return this._highligherOpacity;
  7246. },
  7247. set: function (value) {
  7248. if (this._highligherOpacity === value) {
  7249. return;
  7250. }
  7251. this._highligherOpacity = value;
  7252. this._markAsDirty();
  7253. },
  7254. enumerable: true,
  7255. configurable: true
  7256. });
  7257. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7258. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7259. get: function () {
  7260. return this._onFocusSelectAll;
  7261. },
  7262. set: function (value) {
  7263. if (this._onFocusSelectAll === value) {
  7264. return;
  7265. }
  7266. this._onFocusSelectAll = value;
  7267. this._markAsDirty();
  7268. },
  7269. enumerable: true,
  7270. configurable: true
  7271. });
  7272. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7273. /** Gets or sets the text hightlight color */
  7274. get: function () {
  7275. return this._textHighlightColor;
  7276. },
  7277. set: function (value) {
  7278. if (this._textHighlightColor === value) {
  7279. return;
  7280. }
  7281. this._textHighlightColor = value;
  7282. this._markAsDirty();
  7283. },
  7284. enumerable: true,
  7285. configurable: true
  7286. });
  7287. Object.defineProperty(InputText.prototype, "margin", {
  7288. /** Gets or sets control margin */
  7289. get: function () {
  7290. return this._margin.toString(this._host);
  7291. },
  7292. set: function (value) {
  7293. if (this._margin.toString(this._host) === value) {
  7294. return;
  7295. }
  7296. if (this._margin.fromString(value)) {
  7297. this._markAsDirty();
  7298. }
  7299. },
  7300. enumerable: true,
  7301. configurable: true
  7302. });
  7303. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7304. /** Gets control margin in pixels */
  7305. get: function () {
  7306. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7307. },
  7308. enumerable: true,
  7309. configurable: true
  7310. });
  7311. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7312. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7313. get: function () {
  7314. return this._autoStretchWidth;
  7315. },
  7316. set: function (value) {
  7317. if (this._autoStretchWidth === value) {
  7318. return;
  7319. }
  7320. this._autoStretchWidth = value;
  7321. this._markAsDirty();
  7322. },
  7323. enumerable: true,
  7324. configurable: true
  7325. });
  7326. Object.defineProperty(InputText.prototype, "thickness", {
  7327. /** Gets or sets border thickness */
  7328. get: function () {
  7329. return this._thickness;
  7330. },
  7331. set: function (value) {
  7332. if (this._thickness === value) {
  7333. return;
  7334. }
  7335. this._thickness = value;
  7336. this._markAsDirty();
  7337. },
  7338. enumerable: true,
  7339. configurable: true
  7340. });
  7341. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7342. /** Gets or sets the background color when focused */
  7343. get: function () {
  7344. return this._focusedBackground;
  7345. },
  7346. set: function (value) {
  7347. if (this._focusedBackground === value) {
  7348. return;
  7349. }
  7350. this._focusedBackground = value;
  7351. this._markAsDirty();
  7352. },
  7353. enumerable: true,
  7354. configurable: true
  7355. });
  7356. Object.defineProperty(InputText.prototype, "focusedColor", {
  7357. /** Gets or sets the background color when focused */
  7358. get: function () {
  7359. return this._focusedColor;
  7360. },
  7361. set: function (value) {
  7362. if (this._focusedColor === value) {
  7363. return;
  7364. }
  7365. this._focusedColor = value;
  7366. this._markAsDirty();
  7367. },
  7368. enumerable: true,
  7369. configurable: true
  7370. });
  7371. Object.defineProperty(InputText.prototype, "background", {
  7372. /** Gets or sets the background color */
  7373. get: function () {
  7374. return this._background;
  7375. },
  7376. set: function (value) {
  7377. if (this._background === value) {
  7378. return;
  7379. }
  7380. this._background = value;
  7381. this._markAsDirty();
  7382. },
  7383. enumerable: true,
  7384. configurable: true
  7385. });
  7386. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7387. /** Gets or sets the placeholder color */
  7388. get: function () {
  7389. return this._placeholderColor;
  7390. },
  7391. set: function (value) {
  7392. if (this._placeholderColor === value) {
  7393. return;
  7394. }
  7395. this._placeholderColor = value;
  7396. this._markAsDirty();
  7397. },
  7398. enumerable: true,
  7399. configurable: true
  7400. });
  7401. Object.defineProperty(InputText.prototype, "placeholderText", {
  7402. /** Gets or sets the text displayed when the control is empty */
  7403. get: function () {
  7404. return this._placeholderText;
  7405. },
  7406. set: function (value) {
  7407. if (this._placeholderText === value) {
  7408. return;
  7409. }
  7410. this._placeholderText = value;
  7411. this._markAsDirty();
  7412. },
  7413. enumerable: true,
  7414. configurable: true
  7415. });
  7416. Object.defineProperty(InputText.prototype, "deadKey", {
  7417. /** Gets or sets the dead key flag */
  7418. get: function () {
  7419. return this._deadKey;
  7420. },
  7421. set: function (flag) {
  7422. this._deadKey = flag;
  7423. },
  7424. enumerable: true,
  7425. configurable: true
  7426. });
  7427. Object.defineProperty(InputText.prototype, "highlightedText", {
  7428. /** Gets or sets the highlight text */
  7429. get: function () {
  7430. return this._highlightedText;
  7431. },
  7432. set: function (text) {
  7433. if (this._highlightedText === text) {
  7434. return;
  7435. }
  7436. this._highlightedText = text;
  7437. this._markAsDirty();
  7438. },
  7439. enumerable: true,
  7440. configurable: true
  7441. });
  7442. Object.defineProperty(InputText.prototype, "addKey", {
  7443. /** Gets or sets if the current key should be added */
  7444. get: function () {
  7445. return this._addKey;
  7446. },
  7447. set: function (flag) {
  7448. this._addKey = flag;
  7449. },
  7450. enumerable: true,
  7451. configurable: true
  7452. });
  7453. Object.defineProperty(InputText.prototype, "currentKey", {
  7454. /** Gets or sets the value of the current key being entered */
  7455. get: function () {
  7456. return this._currentKey;
  7457. },
  7458. set: function (key) {
  7459. this._currentKey = key;
  7460. },
  7461. enumerable: true,
  7462. configurable: true
  7463. });
  7464. Object.defineProperty(InputText.prototype, "text", {
  7465. /** Gets or sets the text displayed in the control */
  7466. get: function () {
  7467. return this._text;
  7468. },
  7469. set: function (value) {
  7470. var valueAsString = value.toString(); // Forcing convertion
  7471. if (this._text === valueAsString) {
  7472. return;
  7473. }
  7474. this._text = valueAsString;
  7475. this._markAsDirty();
  7476. this.onTextChangedObservable.notifyObservers(this);
  7477. },
  7478. enumerable: true,
  7479. configurable: true
  7480. });
  7481. Object.defineProperty(InputText.prototype, "width", {
  7482. /** Gets or sets control width */
  7483. get: function () {
  7484. return this._width.toString(this._host);
  7485. },
  7486. set: function (value) {
  7487. if (this._width.toString(this._host) === value) {
  7488. return;
  7489. }
  7490. if (this._width.fromString(value)) {
  7491. this._markAsDirty();
  7492. }
  7493. this.autoStretchWidth = false;
  7494. },
  7495. enumerable: true,
  7496. configurable: true
  7497. });
  7498. /** @hidden */
  7499. InputText.prototype.onBlur = function () {
  7500. this._isFocused = false;
  7501. this._scrollLeft = null;
  7502. this._cursorOffset = 0;
  7503. clearTimeout(this._blinkTimeout);
  7504. this._markAsDirty();
  7505. this.onBlurObservable.notifyObservers(this);
  7506. this._host.unRegisterClipboardEvents();
  7507. if (this._onClipboardObserver) {
  7508. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7509. }
  7510. var scene = this._host.getScene();
  7511. if (this._onPointerDblTapObserver && scene) {
  7512. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7513. }
  7514. };
  7515. /** @hidden */
  7516. InputText.prototype.onFocus = function () {
  7517. var _this = this;
  7518. if (!this._isEnabled) {
  7519. return;
  7520. }
  7521. this._scrollLeft = null;
  7522. this._isFocused = true;
  7523. this._blinkIsEven = false;
  7524. this._cursorOffset = 0;
  7525. this._markAsDirty();
  7526. this.onFocusObservable.notifyObservers(this);
  7527. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7528. var value = prompt(this.promptMessage);
  7529. if (value !== null) {
  7530. this.text = value;
  7531. }
  7532. this._host.focusedControl = null;
  7533. return;
  7534. }
  7535. this._host.registerClipboardEvents();
  7536. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7537. // process clipboard event, can be configured.
  7538. switch (clipboardInfo.type) {
  7539. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7540. _this._onCopyText(clipboardInfo.event);
  7541. _this.onTextCopyObservable.notifyObservers(_this);
  7542. break;
  7543. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7544. _this._onCutText(clipboardInfo.event);
  7545. _this.onTextCutObservable.notifyObservers(_this);
  7546. break;
  7547. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7548. _this._onPasteText(clipboardInfo.event);
  7549. _this.onTextPasteObservable.notifyObservers(_this);
  7550. break;
  7551. default: return;
  7552. }
  7553. });
  7554. var scene = this._host.getScene();
  7555. if (scene) {
  7556. //register the pointer double tap event
  7557. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7558. if (!_this._isFocused) {
  7559. return;
  7560. }
  7561. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7562. _this._processDblClick(pointerInfo);
  7563. }
  7564. });
  7565. }
  7566. if (this._onFocusSelectAll) {
  7567. this._selectAllText();
  7568. }
  7569. };
  7570. InputText.prototype._getTypeName = function () {
  7571. return "InputText";
  7572. };
  7573. /**
  7574. * Function called to get the list of controls that should not steal the focus from this control
  7575. * @returns an array of controls
  7576. */
  7577. InputText.prototype.keepsFocusWith = function () {
  7578. if (!this._connectedVirtualKeyboard) {
  7579. return null;
  7580. }
  7581. return [this._connectedVirtualKeyboard];
  7582. };
  7583. /** @hidden */
  7584. InputText.prototype.processKey = function (keyCode, key, evt) {
  7585. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7586. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7587. return;
  7588. }
  7589. //select all
  7590. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7591. this._selectAllText();
  7592. evt.preventDefault();
  7593. return;
  7594. }
  7595. // Specific cases
  7596. switch (keyCode) {
  7597. case 32: //SPACE
  7598. key = " "; //ie11 key for space is "Spacebar"
  7599. break;
  7600. case 191: //SLASH
  7601. if (evt) {
  7602. evt.preventDefault();
  7603. }
  7604. break;
  7605. case 8: // BACKSPACE
  7606. if (this._text && this._text.length > 0) {
  7607. //delete the highlighted text
  7608. if (this._isTextHighlightOn) {
  7609. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7610. this._isTextHighlightOn = false;
  7611. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7612. this._blinkIsEven = false;
  7613. if (evt) {
  7614. evt.preventDefault();
  7615. }
  7616. return;
  7617. }
  7618. //delete single character
  7619. if (this._cursorOffset === 0) {
  7620. this.text = this._text.substr(0, this._text.length - 1);
  7621. }
  7622. else {
  7623. var deletePosition = this._text.length - this._cursorOffset;
  7624. if (deletePosition > 0) {
  7625. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7626. }
  7627. }
  7628. }
  7629. if (evt) {
  7630. evt.preventDefault();
  7631. }
  7632. return;
  7633. case 46: // DELETE
  7634. if (this._isTextHighlightOn) {
  7635. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7636. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7637. while (decrementor > 0 && this._cursorOffset > 0) {
  7638. this._cursorOffset--;
  7639. }
  7640. this._isTextHighlightOn = false;
  7641. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7642. if (evt) {
  7643. evt.preventDefault();
  7644. }
  7645. return;
  7646. }
  7647. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7648. var deletePosition = this._text.length - this._cursorOffset;
  7649. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7650. this._cursorOffset--;
  7651. }
  7652. if (evt) {
  7653. evt.preventDefault();
  7654. }
  7655. return;
  7656. case 13: // RETURN
  7657. this._host.focusedControl = null;
  7658. this._isTextHighlightOn = false;
  7659. return;
  7660. case 35: // END
  7661. this._cursorOffset = 0;
  7662. this._blinkIsEven = false;
  7663. this._isTextHighlightOn = false;
  7664. this._markAsDirty();
  7665. return;
  7666. case 36: // HOME
  7667. this._cursorOffset = this._text.length;
  7668. this._blinkIsEven = false;
  7669. this._isTextHighlightOn = false;
  7670. this._markAsDirty();
  7671. return;
  7672. case 37: // LEFT
  7673. this._cursorOffset++;
  7674. if (this._cursorOffset > this._text.length) {
  7675. this._cursorOffset = this._text.length;
  7676. }
  7677. if (evt && evt.shiftKey) {
  7678. // update the cursor
  7679. this._blinkIsEven = false;
  7680. // shift + ctrl/cmd + <-
  7681. if (evt.ctrlKey || evt.metaKey) {
  7682. if (!this._isTextHighlightOn) {
  7683. if (this._text.length === this._cursorOffset) {
  7684. return;
  7685. }
  7686. else {
  7687. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7688. }
  7689. }
  7690. this._startHighlightIndex = 0;
  7691. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7692. this._cursorOffset = this._text.length;
  7693. this._isTextHighlightOn = true;
  7694. this._markAsDirty();
  7695. return;
  7696. }
  7697. //store the starting point
  7698. if (!this._isTextHighlightOn) {
  7699. this._isTextHighlightOn = true;
  7700. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7701. }
  7702. //if text is already highlighted
  7703. else if (this._cursorIndex === -1) {
  7704. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7705. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7706. }
  7707. //set the highlight indexes
  7708. if (this._cursorIndex < this._cursorOffset) {
  7709. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7710. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7711. }
  7712. else if (this._cursorIndex > this._cursorOffset) {
  7713. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7714. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7715. }
  7716. else {
  7717. this._isTextHighlightOn = false;
  7718. }
  7719. this._markAsDirty();
  7720. return;
  7721. }
  7722. if (this._isTextHighlightOn) {
  7723. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7724. this._isTextHighlightOn = false;
  7725. }
  7726. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7727. this._cursorOffset = this.text.length;
  7728. evt.preventDefault();
  7729. }
  7730. this._blinkIsEven = false;
  7731. this._isTextHighlightOn = false;
  7732. this._cursorIndex = -1;
  7733. this._markAsDirty();
  7734. return;
  7735. case 39: // RIGHT
  7736. this._cursorOffset--;
  7737. if (this._cursorOffset < 0) {
  7738. this._cursorOffset = 0;
  7739. }
  7740. if (evt && evt.shiftKey) {
  7741. //update the cursor
  7742. this._blinkIsEven = false;
  7743. //shift + ctrl/cmd + ->
  7744. if (evt.ctrlKey || evt.metaKey) {
  7745. if (!this._isTextHighlightOn) {
  7746. if (this._cursorOffset === 0) {
  7747. return;
  7748. }
  7749. else {
  7750. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7751. }
  7752. }
  7753. this._endHighlightIndex = this._text.length;
  7754. this._isTextHighlightOn = true;
  7755. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7756. this._cursorOffset = 0;
  7757. this._markAsDirty();
  7758. return;
  7759. }
  7760. if (!this._isTextHighlightOn) {
  7761. this._isTextHighlightOn = true;
  7762. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7763. }
  7764. //if text is already highlighted
  7765. else if (this._cursorIndex === -1) {
  7766. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7767. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7768. }
  7769. //set the highlight indexes
  7770. if (this._cursorIndex < this._cursorOffset) {
  7771. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7772. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7773. }
  7774. else if (this._cursorIndex > this._cursorOffset) {
  7775. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7776. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7777. }
  7778. else {
  7779. this._isTextHighlightOn = false;
  7780. }
  7781. this._markAsDirty();
  7782. return;
  7783. }
  7784. if (this._isTextHighlightOn) {
  7785. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7786. this._isTextHighlightOn = false;
  7787. }
  7788. //ctr + ->
  7789. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7790. this._cursorOffset = 0;
  7791. evt.preventDefault();
  7792. }
  7793. this._blinkIsEven = false;
  7794. this._isTextHighlightOn = false;
  7795. this._cursorIndex = -1;
  7796. this._markAsDirty();
  7797. return;
  7798. case 222: // Dead
  7799. if (evt) {
  7800. evt.preventDefault();
  7801. }
  7802. this._cursorIndex = -1;
  7803. this.deadKey = true;
  7804. break;
  7805. }
  7806. // Printable characters
  7807. if (key &&
  7808. ((keyCode === -1) || // Direct access
  7809. (keyCode === 32) || // Space
  7810. (keyCode > 47 && keyCode < 64) || // Numbers
  7811. (keyCode > 64 && keyCode < 91) || // Letters
  7812. (keyCode > 159 && keyCode < 193) || // Special characters
  7813. (keyCode > 218 && keyCode < 223) || // Special characters
  7814. (keyCode > 95 && keyCode < 112))) { // Numpad
  7815. this._currentKey = key;
  7816. this.onBeforeKeyAddObservable.notifyObservers(this);
  7817. key = this._currentKey;
  7818. if (this._addKey) {
  7819. if (this._isTextHighlightOn) {
  7820. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7821. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7822. this._isTextHighlightOn = false;
  7823. this._blinkIsEven = false;
  7824. this._markAsDirty();
  7825. }
  7826. else if (this._cursorOffset === 0) {
  7827. this.text += key;
  7828. }
  7829. else {
  7830. var insertPosition = this._text.length - this._cursorOffset;
  7831. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7832. }
  7833. }
  7834. }
  7835. };
  7836. /** @hidden */
  7837. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7838. //update the cursor
  7839. this._blinkIsEven = false;
  7840. if (this._cursorIndex === -1) {
  7841. this._cursorIndex = offset;
  7842. }
  7843. else {
  7844. if (this._cursorIndex < this._cursorOffset) {
  7845. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7846. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7847. }
  7848. else if (this._cursorIndex > this._cursorOffset) {
  7849. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7850. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7851. }
  7852. else {
  7853. this._isTextHighlightOn = false;
  7854. this._markAsDirty();
  7855. return;
  7856. }
  7857. }
  7858. this._isTextHighlightOn = true;
  7859. this._markAsDirty();
  7860. };
  7861. /** @hidden */
  7862. InputText.prototype._processDblClick = function (evt) {
  7863. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7864. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7865. this._endHighlightIndex = this._startHighlightIndex;
  7866. var rWord = /\w+/g, moveLeft, moveRight;
  7867. do {
  7868. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7869. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7870. } while (moveLeft || moveRight);
  7871. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7872. this.onTextHighlightObservable.notifyObservers(this);
  7873. this._isTextHighlightOn = true;
  7874. this._clickedCoordinate = null;
  7875. this._blinkIsEven = true;
  7876. this._cursorIndex = -1;
  7877. this._markAsDirty();
  7878. };
  7879. /** @hidden */
  7880. InputText.prototype._selectAllText = function () {
  7881. this._blinkIsEven = true;
  7882. this._isTextHighlightOn = true;
  7883. this._startHighlightIndex = 0;
  7884. this._endHighlightIndex = this._text.length;
  7885. this._cursorOffset = this._text.length;
  7886. this._cursorIndex = -1;
  7887. this._markAsDirty();
  7888. };
  7889. /**
  7890. * Handles the keyboard event
  7891. * @param evt Defines the KeyboardEvent
  7892. */
  7893. InputText.prototype.processKeyboard = function (evt) {
  7894. // process pressed key
  7895. this.processKey(evt.keyCode, evt.key, evt);
  7896. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7897. };
  7898. /** @hidden */
  7899. InputText.prototype._onCopyText = function (ev) {
  7900. this._isTextHighlightOn = false;
  7901. //when write permission to clipbaord data is denied
  7902. try {
  7903. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7904. }
  7905. catch (_a) { } //pass
  7906. this._host.clipboardData = this._highlightedText;
  7907. };
  7908. /** @hidden */
  7909. InputText.prototype._onCutText = function (ev) {
  7910. if (!this._highlightedText) {
  7911. return;
  7912. }
  7913. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7914. this._isTextHighlightOn = false;
  7915. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7916. //when write permission to clipbaord data is denied
  7917. try {
  7918. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7919. }
  7920. catch (_a) { } //pass
  7921. this._host.clipboardData = this._highlightedText;
  7922. this._highlightedText = "";
  7923. };
  7924. /** @hidden */
  7925. InputText.prototype._onPasteText = function (ev) {
  7926. var data = "";
  7927. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7928. data = ev.clipboardData.getData("text/plain");
  7929. }
  7930. else {
  7931. //get the cached data; returns blank string by default
  7932. data = this._host.clipboardData;
  7933. }
  7934. var insertPosition = this._text.length - this._cursorOffset;
  7935. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7936. };
  7937. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7938. var _this = this;
  7939. context.save();
  7940. this._applyStates(context);
  7941. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7942. context.shadowColor = this.shadowColor;
  7943. context.shadowBlur = this.shadowBlur;
  7944. context.shadowOffsetX = this.shadowOffsetX;
  7945. context.shadowOffsetY = this.shadowOffsetY;
  7946. }
  7947. // Background
  7948. if (this._isFocused) {
  7949. if (this._focusedBackground) {
  7950. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7951. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7952. }
  7953. }
  7954. else if (this._background) {
  7955. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7956. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7957. }
  7958. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7959. context.shadowBlur = 0;
  7960. context.shadowOffsetX = 0;
  7961. context.shadowOffsetY = 0;
  7962. }
  7963. if (!this._fontOffset) {
  7964. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7965. }
  7966. // Text
  7967. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7968. if (this.color) {
  7969. context.fillStyle = this.color;
  7970. }
  7971. var text = this._beforeRenderText(this._text);
  7972. if (!this._isFocused && !this._text && this._placeholderText) {
  7973. text = this._placeholderText;
  7974. if (this._placeholderColor) {
  7975. context.fillStyle = this._placeholderColor;
  7976. }
  7977. }
  7978. this._textWidth = context.measureText(text).width;
  7979. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7980. if (this._autoStretchWidth) {
  7981. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7982. }
  7983. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7984. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7985. context.save();
  7986. context.beginPath();
  7987. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7988. context.clip();
  7989. if (this._isFocused && this._textWidth > availableWidth) {
  7990. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7991. if (!this._scrollLeft) {
  7992. this._scrollLeft = textLeft;
  7993. }
  7994. }
  7995. else {
  7996. this._scrollLeft = clipTextLeft;
  7997. }
  7998. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7999. // Cursor
  8000. if (this._isFocused) {
  8001. // Need to move cursor
  8002. if (this._clickedCoordinate) {
  8003. var rightPosition = this._scrollLeft + this._textWidth;
  8004. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8005. var currentSize = 0;
  8006. this._cursorOffset = 0;
  8007. var previousDist = 0;
  8008. do {
  8009. if (this._cursorOffset) {
  8010. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8011. }
  8012. this._cursorOffset++;
  8013. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8014. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8015. // Find closest move
  8016. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8017. this._cursorOffset--;
  8018. }
  8019. this._blinkIsEven = false;
  8020. this._clickedCoordinate = null;
  8021. }
  8022. // Render cursor
  8023. if (!this._blinkIsEven) {
  8024. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8025. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8026. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8027. if (cursorLeft < clipTextLeft) {
  8028. this._scrollLeft += (clipTextLeft - cursorLeft);
  8029. cursorLeft = clipTextLeft;
  8030. this._markAsDirty();
  8031. }
  8032. else if (cursorLeft > clipTextLeft + availableWidth) {
  8033. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8034. cursorLeft = clipTextLeft + availableWidth;
  8035. this._markAsDirty();
  8036. }
  8037. if (!this._isTextHighlightOn) {
  8038. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8039. }
  8040. }
  8041. clearTimeout(this._blinkTimeout);
  8042. this._blinkTimeout = setTimeout(function () {
  8043. _this._blinkIsEven = !_this._blinkIsEven;
  8044. _this._markAsDirty();
  8045. }, 500);
  8046. //show the highlighted text
  8047. if (this._isTextHighlightOn) {
  8048. clearTimeout(this._blinkTimeout);
  8049. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8050. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8051. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8052. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8053. if (highlightCursorLeft < clipTextLeft) {
  8054. width = width - (clipTextLeft - highlightCursorLeft);
  8055. if (!width) {
  8056. // when using left arrow on text.length > availableWidth;
  8057. // assigns the width of the first letter after clipTextLeft
  8058. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8059. }
  8060. highlightCursorLeft = clipTextLeft;
  8061. }
  8062. //for transparancy
  8063. context.globalAlpha = this._highligherOpacity;
  8064. context.fillStyle = this._textHighlightColor;
  8065. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8066. context.globalAlpha = 1.0;
  8067. }
  8068. }
  8069. context.restore();
  8070. // Border
  8071. if (this._thickness) {
  8072. if (this._isFocused) {
  8073. if (this.focusedColor) {
  8074. context.strokeStyle = this.focusedColor;
  8075. }
  8076. }
  8077. else {
  8078. if (this.color) {
  8079. context.strokeStyle = this.color;
  8080. }
  8081. }
  8082. context.lineWidth = this._thickness;
  8083. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8084. }
  8085. context.restore();
  8086. };
  8087. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8088. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8089. return false;
  8090. }
  8091. this._clickedCoordinate = coordinates.x;
  8092. this._isTextHighlightOn = false;
  8093. this._highlightedText = "";
  8094. this._cursorIndex = -1;
  8095. this._isPointerDown = true;
  8096. this._host._capturingControl[pointerId] = this;
  8097. if (this._host.focusedControl === this) {
  8098. // Move cursor
  8099. clearTimeout(this._blinkTimeout);
  8100. this._markAsDirty();
  8101. return true;
  8102. }
  8103. if (!this._isEnabled) {
  8104. return false;
  8105. }
  8106. this._host.focusedControl = this;
  8107. return true;
  8108. };
  8109. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8110. if (this._host.focusedControl === this && this._isPointerDown) {
  8111. this._clickedCoordinate = coordinates.x;
  8112. this._markAsDirty();
  8113. this._updateValueFromCursorIndex(this._cursorOffset);
  8114. }
  8115. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8116. };
  8117. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8118. this._isPointerDown = false;
  8119. delete this._host._capturingControl[pointerId];
  8120. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8121. };
  8122. InputText.prototype._beforeRenderText = function (text) {
  8123. return text;
  8124. };
  8125. InputText.prototype.dispose = function () {
  8126. _super.prototype.dispose.call(this);
  8127. this.onBlurObservable.clear();
  8128. this.onFocusObservable.clear();
  8129. this.onTextChangedObservable.clear();
  8130. this.onTextCopyObservable.clear();
  8131. this.onTextCutObservable.clear();
  8132. this.onTextPasteObservable.clear();
  8133. this.onTextHighlightObservable.clear();
  8134. this.onKeyboardEventProcessedObservable.clear();
  8135. };
  8136. return InputText;
  8137. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8138. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8139. /***/ }),
  8140. /***/ "./2D/controls/line.ts":
  8141. /*!*****************************!*\
  8142. !*** ./2D/controls/line.ts ***!
  8143. \*****************************/
  8144. /*! exports provided: Line */
  8145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8146. "use strict";
  8147. __webpack_require__.r(__webpack_exports__);
  8148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8149. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8150. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  8151. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8152. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8153. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8154. /** Class used to render 2D lines */
  8155. var Line = /** @class */ (function (_super) {
  8156. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8157. /**
  8158. * Creates a new Line
  8159. * @param name defines the control name
  8160. */
  8161. function Line(name) {
  8162. var _this = _super.call(this, name) || this;
  8163. _this.name = name;
  8164. _this._lineWidth = 1;
  8165. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8166. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8167. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8168. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8169. _this._dash = new Array();
  8170. _this._automaticSize = true;
  8171. _this.isHitTestVisible = false;
  8172. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8173. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8174. return _this;
  8175. }
  8176. Object.defineProperty(Line.prototype, "dash", {
  8177. /** Gets or sets the dash pattern */
  8178. get: function () {
  8179. return this._dash;
  8180. },
  8181. set: function (value) {
  8182. if (this._dash === value) {
  8183. return;
  8184. }
  8185. this._dash = value;
  8186. this._markAsDirty();
  8187. },
  8188. enumerable: true,
  8189. configurable: true
  8190. });
  8191. Object.defineProperty(Line.prototype, "connectedControl", {
  8192. /** Gets or sets the control connected with the line end */
  8193. get: function () {
  8194. return this._connectedControl;
  8195. },
  8196. set: function (value) {
  8197. var _this = this;
  8198. if (this._connectedControl === value) {
  8199. return;
  8200. }
  8201. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8202. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8203. this._connectedControlDirtyObserver = null;
  8204. }
  8205. if (value) {
  8206. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8207. }
  8208. this._connectedControl = value;
  8209. this._markAsDirty();
  8210. },
  8211. enumerable: true,
  8212. configurable: true
  8213. });
  8214. Object.defineProperty(Line.prototype, "x1", {
  8215. /** Gets or sets start coordinates on X axis */
  8216. get: function () {
  8217. return this._x1.toString(this._host);
  8218. },
  8219. set: function (value) {
  8220. if (this._x1.toString(this._host) === value) {
  8221. return;
  8222. }
  8223. if (this._x1.fromString(value)) {
  8224. this._markAsDirty();
  8225. }
  8226. },
  8227. enumerable: true,
  8228. configurable: true
  8229. });
  8230. Object.defineProperty(Line.prototype, "y1", {
  8231. /** Gets or sets start coordinates on Y axis */
  8232. get: function () {
  8233. return this._y1.toString(this._host);
  8234. },
  8235. set: function (value) {
  8236. if (this._y1.toString(this._host) === value) {
  8237. return;
  8238. }
  8239. if (this._y1.fromString(value)) {
  8240. this._markAsDirty();
  8241. }
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. Object.defineProperty(Line.prototype, "x2", {
  8247. /** Gets or sets end coordinates on X axis */
  8248. get: function () {
  8249. return this._x2.toString(this._host);
  8250. },
  8251. set: function (value) {
  8252. if (this._x2.toString(this._host) === value) {
  8253. return;
  8254. }
  8255. if (this._x2.fromString(value)) {
  8256. this._markAsDirty();
  8257. }
  8258. },
  8259. enumerable: true,
  8260. configurable: true
  8261. });
  8262. Object.defineProperty(Line.prototype, "y2", {
  8263. /** Gets or sets end coordinates on Y axis */
  8264. get: function () {
  8265. return this._y2.toString(this._host);
  8266. },
  8267. set: function (value) {
  8268. if (this._y2.toString(this._host) === value) {
  8269. return;
  8270. }
  8271. if (this._y2.fromString(value)) {
  8272. this._markAsDirty();
  8273. }
  8274. },
  8275. enumerable: true,
  8276. configurable: true
  8277. });
  8278. Object.defineProperty(Line.prototype, "lineWidth", {
  8279. /** Gets or sets line width */
  8280. get: function () {
  8281. return this._lineWidth;
  8282. },
  8283. set: function (value) {
  8284. if (this._lineWidth === value) {
  8285. return;
  8286. }
  8287. this._lineWidth = value;
  8288. this._markAsDirty();
  8289. },
  8290. enumerable: true,
  8291. configurable: true
  8292. });
  8293. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8294. /** Gets or sets horizontal alignment */
  8295. set: function (value) {
  8296. return;
  8297. },
  8298. enumerable: true,
  8299. configurable: true
  8300. });
  8301. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8302. /** Gets or sets vertical alignment */
  8303. set: function (value) {
  8304. return;
  8305. },
  8306. enumerable: true,
  8307. configurable: true
  8308. });
  8309. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8310. get: function () {
  8311. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8312. },
  8313. enumerable: true,
  8314. configurable: true
  8315. });
  8316. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8317. get: function () {
  8318. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8319. },
  8320. enumerable: true,
  8321. configurable: true
  8322. });
  8323. Line.prototype._getTypeName = function () {
  8324. return "Line";
  8325. };
  8326. Line.prototype._draw = function (context) {
  8327. context.save();
  8328. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8329. context.shadowColor = this.shadowColor;
  8330. context.shadowBlur = this.shadowBlur;
  8331. context.shadowOffsetX = this.shadowOffsetX;
  8332. context.shadowOffsetY = this.shadowOffsetY;
  8333. }
  8334. this._applyStates(context);
  8335. context.strokeStyle = this.color;
  8336. context.lineWidth = this._lineWidth;
  8337. context.setLineDash(this._dash);
  8338. context.beginPath();
  8339. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8340. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8341. context.stroke();
  8342. context.restore();
  8343. };
  8344. Line.prototype._measure = function () {
  8345. // Width / Height
  8346. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8347. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8348. };
  8349. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8350. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8351. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8352. };
  8353. /**
  8354. * Move one end of the line given 3D cartesian coordinates.
  8355. * @param position Targeted world position
  8356. * @param scene Scene
  8357. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8358. */
  8359. Line.prototype.moveToVector3 = function (position, scene, end) {
  8360. if (end === void 0) { end = false; }
  8361. if (!this._host || this.parent !== this._host._rootContainer) {
  8362. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8363. return;
  8364. }
  8365. var globalViewport = this._host._getGlobalViewport(scene);
  8366. var projectedPosition = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8367. this._moveToProjectedPosition(projectedPosition, end);
  8368. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8369. this.notRenderable = true;
  8370. return;
  8371. }
  8372. this.notRenderable = false;
  8373. };
  8374. /**
  8375. * Move one end of the line to a position in screen absolute space.
  8376. * @param projectedPosition Position in screen absolute space (X, Y)
  8377. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8378. */
  8379. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8380. if (end === void 0) { end = false; }
  8381. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8382. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8383. if (end) {
  8384. this.x2 = x;
  8385. this.y2 = y;
  8386. this._x2.ignoreAdaptiveScaling = true;
  8387. this._y2.ignoreAdaptiveScaling = true;
  8388. }
  8389. else {
  8390. this.x1 = x;
  8391. this.y1 = y;
  8392. this._x1.ignoreAdaptiveScaling = true;
  8393. this._y1.ignoreAdaptiveScaling = true;
  8394. }
  8395. };
  8396. return Line;
  8397. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8398. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8399. /***/ }),
  8400. /***/ "./2D/controls/multiLine.ts":
  8401. /*!**********************************!*\
  8402. !*** ./2D/controls/multiLine.ts ***!
  8403. \**********************************/
  8404. /*! exports provided: MultiLine */
  8405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8406. "use strict";
  8407. __webpack_require__.r(__webpack_exports__);
  8408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8409. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8410. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math.vector");
  8411. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8412. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8413. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8414. /**
  8415. * Class used to create multi line control
  8416. */
  8417. var MultiLine = /** @class */ (function (_super) {
  8418. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8419. /**
  8420. * Creates a new MultiLine
  8421. * @param name defines the control name
  8422. */
  8423. function MultiLine(name) {
  8424. var _this = _super.call(this, name) || this;
  8425. _this.name = name;
  8426. _this._lineWidth = 1;
  8427. /** Function called when a point is updated */
  8428. _this.onPointUpdate = function () {
  8429. _this._markAsDirty();
  8430. };
  8431. _this._automaticSize = true;
  8432. _this.isHitTestVisible = false;
  8433. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8434. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8435. _this._dash = [];
  8436. _this._points = [];
  8437. return _this;
  8438. }
  8439. Object.defineProperty(MultiLine.prototype, "dash", {
  8440. /** Gets or sets dash pattern */
  8441. get: function () {
  8442. return this._dash;
  8443. },
  8444. set: function (value) {
  8445. if (this._dash === value) {
  8446. return;
  8447. }
  8448. this._dash = value;
  8449. this._markAsDirty();
  8450. },
  8451. enumerable: true,
  8452. configurable: true
  8453. });
  8454. /**
  8455. * Gets point stored at specified index
  8456. * @param index defines the index to look for
  8457. * @returns the requested point if found
  8458. */
  8459. MultiLine.prototype.getAt = function (index) {
  8460. if (!this._points[index]) {
  8461. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8462. }
  8463. return this._points[index];
  8464. };
  8465. /**
  8466. * Adds new points to the point collection
  8467. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8468. * @returns the list of created MultiLinePoint
  8469. */
  8470. MultiLine.prototype.add = function () {
  8471. var _this = this;
  8472. var items = [];
  8473. for (var _i = 0; _i < arguments.length; _i++) {
  8474. items[_i] = arguments[_i];
  8475. }
  8476. return items.map(function (item) { return _this.push(item); });
  8477. };
  8478. /**
  8479. * Adds a new point to the point collection
  8480. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8481. * @returns the created MultiLinePoint
  8482. */
  8483. MultiLine.prototype.push = function (item) {
  8484. var point = this.getAt(this._points.length);
  8485. if (item == null) {
  8486. return point;
  8487. }
  8488. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8489. point.mesh = item;
  8490. }
  8491. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8492. point.control = item;
  8493. }
  8494. else if (item.x != null && item.y != null) {
  8495. point.x = item.x;
  8496. point.y = item.y;
  8497. }
  8498. return point;
  8499. };
  8500. /**
  8501. * Remove a specific value or point from the active point collection
  8502. * @param value defines the value or point to remove
  8503. */
  8504. MultiLine.prototype.remove = function (value) {
  8505. var index;
  8506. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8507. index = this._points.indexOf(value);
  8508. if (index === -1) {
  8509. return;
  8510. }
  8511. }
  8512. else {
  8513. index = value;
  8514. }
  8515. var point = this._points[index];
  8516. if (!point) {
  8517. return;
  8518. }
  8519. point.dispose();
  8520. this._points.splice(index, 1);
  8521. };
  8522. /**
  8523. * Resets this object to initial state (no point)
  8524. */
  8525. MultiLine.prototype.reset = function () {
  8526. while (this._points.length > 0) {
  8527. this.remove(this._points.length - 1);
  8528. }
  8529. };
  8530. /**
  8531. * Resets all links
  8532. */
  8533. MultiLine.prototype.resetLinks = function () {
  8534. this._points.forEach(function (point) {
  8535. if (point != null) {
  8536. point.resetLinks();
  8537. }
  8538. });
  8539. };
  8540. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8541. /** Gets or sets line width */
  8542. get: function () {
  8543. return this._lineWidth;
  8544. },
  8545. set: function (value) {
  8546. if (this._lineWidth === value) {
  8547. return;
  8548. }
  8549. this._lineWidth = value;
  8550. this._markAsDirty();
  8551. },
  8552. enumerable: true,
  8553. configurable: true
  8554. });
  8555. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8556. set: function (value) {
  8557. return;
  8558. },
  8559. enumerable: true,
  8560. configurable: true
  8561. });
  8562. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8563. set: function (value) {
  8564. return;
  8565. },
  8566. enumerable: true,
  8567. configurable: true
  8568. });
  8569. MultiLine.prototype._getTypeName = function () {
  8570. return "MultiLine";
  8571. };
  8572. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8573. context.save();
  8574. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8575. context.shadowColor = this.shadowColor;
  8576. context.shadowBlur = this.shadowBlur;
  8577. context.shadowOffsetX = this.shadowOffsetX;
  8578. context.shadowOffsetY = this.shadowOffsetY;
  8579. }
  8580. this._applyStates(context);
  8581. context.strokeStyle = this.color;
  8582. context.lineWidth = this._lineWidth;
  8583. context.setLineDash(this._dash);
  8584. context.beginPath();
  8585. var first = true; //first index is not necessarily 0
  8586. this._points.forEach(function (point) {
  8587. if (!point) {
  8588. return;
  8589. }
  8590. if (first) {
  8591. context.moveTo(point._point.x, point._point.y);
  8592. first = false;
  8593. }
  8594. else {
  8595. context.lineTo(point._point.x, point._point.y);
  8596. }
  8597. });
  8598. context.stroke();
  8599. context.restore();
  8600. };
  8601. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8602. var _this = this;
  8603. this._minX = null;
  8604. this._minY = null;
  8605. this._maxX = null;
  8606. this._maxY = null;
  8607. this._points.forEach(function (point, index) {
  8608. if (!point) {
  8609. return;
  8610. }
  8611. point.translate();
  8612. if (_this._minX == null || point._point.x < _this._minX) {
  8613. _this._minX = point._point.x;
  8614. }
  8615. if (_this._minY == null || point._point.y < _this._minY) {
  8616. _this._minY = point._point.y;
  8617. }
  8618. if (_this._maxX == null || point._point.x > _this._maxX) {
  8619. _this._maxX = point._point.x;
  8620. }
  8621. if (_this._maxY == null || point._point.y > _this._maxY) {
  8622. _this._maxY = point._point.y;
  8623. }
  8624. });
  8625. if (this._minX == null) {
  8626. this._minX = 0;
  8627. }
  8628. if (this._minY == null) {
  8629. this._minY = 0;
  8630. }
  8631. if (this._maxX == null) {
  8632. this._maxX = 0;
  8633. }
  8634. if (this._maxY == null) {
  8635. this._maxY = 0;
  8636. }
  8637. };
  8638. MultiLine.prototype._measure = function () {
  8639. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8640. return;
  8641. }
  8642. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8643. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8644. };
  8645. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8646. if (this._minX == null || this._minY == null) {
  8647. return;
  8648. }
  8649. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8650. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8651. };
  8652. MultiLine.prototype.dispose = function () {
  8653. this.reset();
  8654. _super.prototype.dispose.call(this);
  8655. };
  8656. return MultiLine;
  8657. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8658. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8659. /***/ }),
  8660. /***/ "./2D/controls/radioButton.ts":
  8661. /*!************************************!*\
  8662. !*** ./2D/controls/radioButton.ts ***!
  8663. \************************************/
  8664. /*! exports provided: RadioButton */
  8665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8666. "use strict";
  8667. __webpack_require__.r(__webpack_exports__);
  8668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8670. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  8671. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8672. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8673. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8674. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8675. /**
  8676. * Class used to create radio button controls
  8677. */
  8678. var RadioButton = /** @class */ (function (_super) {
  8679. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8680. /**
  8681. * Creates a new RadioButton
  8682. * @param name defines the control name
  8683. */
  8684. function RadioButton(name) {
  8685. var _this = _super.call(this, name) || this;
  8686. _this.name = name;
  8687. _this._isChecked = false;
  8688. _this._background = "black";
  8689. _this._checkSizeRatio = 0.8;
  8690. _this._thickness = 1;
  8691. /** Gets or sets group name */
  8692. _this.group = "";
  8693. /** Observable raised when isChecked is changed */
  8694. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8695. _this.isPointerBlocker = true;
  8696. return _this;
  8697. }
  8698. Object.defineProperty(RadioButton.prototype, "thickness", {
  8699. /** Gets or sets border thickness */
  8700. get: function () {
  8701. return this._thickness;
  8702. },
  8703. set: function (value) {
  8704. if (this._thickness === value) {
  8705. return;
  8706. }
  8707. this._thickness = value;
  8708. this._markAsDirty();
  8709. },
  8710. enumerable: true,
  8711. configurable: true
  8712. });
  8713. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8714. /** Gets or sets a value indicating the ratio between overall size and check size */
  8715. get: function () {
  8716. return this._checkSizeRatio;
  8717. },
  8718. set: function (value) {
  8719. value = Math.max(Math.min(1, value), 0);
  8720. if (this._checkSizeRatio === value) {
  8721. return;
  8722. }
  8723. this._checkSizeRatio = value;
  8724. this._markAsDirty();
  8725. },
  8726. enumerable: true,
  8727. configurable: true
  8728. });
  8729. Object.defineProperty(RadioButton.prototype, "background", {
  8730. /** Gets or sets background color */
  8731. get: function () {
  8732. return this._background;
  8733. },
  8734. set: function (value) {
  8735. if (this._background === value) {
  8736. return;
  8737. }
  8738. this._background = value;
  8739. this._markAsDirty();
  8740. },
  8741. enumerable: true,
  8742. configurable: true
  8743. });
  8744. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8745. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8746. get: function () {
  8747. return this._isChecked;
  8748. },
  8749. set: function (value) {
  8750. var _this = this;
  8751. if (this._isChecked === value) {
  8752. return;
  8753. }
  8754. this._isChecked = value;
  8755. this._markAsDirty();
  8756. this.onIsCheckedChangedObservable.notifyObservers(value);
  8757. if (this._isChecked && this._host) {
  8758. // Update all controls from same group
  8759. this._host.executeOnAllControls(function (control) {
  8760. if (control === _this) {
  8761. return;
  8762. }
  8763. if (control.group === undefined) {
  8764. return;
  8765. }
  8766. var childRadio = control;
  8767. if (childRadio.group === _this.group) {
  8768. childRadio.isChecked = false;
  8769. }
  8770. });
  8771. }
  8772. },
  8773. enumerable: true,
  8774. configurable: true
  8775. });
  8776. RadioButton.prototype._getTypeName = function () {
  8777. return "RadioButton";
  8778. };
  8779. RadioButton.prototype._draw = function (context) {
  8780. context.save();
  8781. this._applyStates(context);
  8782. var actualWidth = this._currentMeasure.width - this._thickness;
  8783. var actualHeight = this._currentMeasure.height - this._thickness;
  8784. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8785. context.shadowColor = this.shadowColor;
  8786. context.shadowBlur = this.shadowBlur;
  8787. context.shadowOffsetX = this.shadowOffsetX;
  8788. context.shadowOffsetY = this.shadowOffsetY;
  8789. }
  8790. // Outer
  8791. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  8792. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8793. context.fill();
  8794. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8795. context.shadowBlur = 0;
  8796. context.shadowOffsetX = 0;
  8797. context.shadowOffsetY = 0;
  8798. }
  8799. context.strokeStyle = this.color;
  8800. context.lineWidth = this._thickness;
  8801. context.stroke();
  8802. // Inner
  8803. if (this._isChecked) {
  8804. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8805. var offsetWidth = actualWidth * this._checkSizeRatio;
  8806. var offseHeight = actualHeight * this._checkSizeRatio;
  8807. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  8808. context.fill();
  8809. }
  8810. context.restore();
  8811. };
  8812. // Events
  8813. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8814. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8815. return false;
  8816. }
  8817. if (!this.isChecked) {
  8818. this.isChecked = true;
  8819. }
  8820. return true;
  8821. };
  8822. /**
  8823. * Utility function to easily create a radio button with a header
  8824. * @param title defines the label to use for the header
  8825. * @param group defines the group to use for the radio button
  8826. * @param isChecked defines the initial state of the radio button
  8827. * @param onValueChanged defines the callback to call when value changes
  8828. * @returns a StackPanel containing the radio button and a textBlock
  8829. */
  8830. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8831. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8832. panel.isVertical = false;
  8833. panel.height = "30px";
  8834. var radio = new RadioButton();
  8835. radio.width = "20px";
  8836. radio.height = "20px";
  8837. radio.isChecked = isChecked;
  8838. radio.color = "green";
  8839. radio.group = group;
  8840. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8841. panel.addControl(radio);
  8842. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8843. header.text = title;
  8844. header.width = "180px";
  8845. header.paddingLeft = "5px";
  8846. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8847. header.color = "white";
  8848. panel.addControl(header);
  8849. return panel;
  8850. };
  8851. return RadioButton;
  8852. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8853. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8854. /***/ }),
  8855. /***/ "./2D/controls/rectangle.ts":
  8856. /*!**********************************!*\
  8857. !*** ./2D/controls/rectangle.ts ***!
  8858. \**********************************/
  8859. /*! exports provided: Rectangle */
  8860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8861. "use strict";
  8862. __webpack_require__.r(__webpack_exports__);
  8863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8864. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8865. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8866. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  8867. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8868. /** Class used to create rectangle container */
  8869. var Rectangle = /** @class */ (function (_super) {
  8870. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8871. /**
  8872. * Creates a new Rectangle
  8873. * @param name defines the control name
  8874. */
  8875. function Rectangle(name) {
  8876. var _this = _super.call(this, name) || this;
  8877. _this.name = name;
  8878. _this._thickness = 1;
  8879. _this._cornerRadius = 0;
  8880. return _this;
  8881. }
  8882. Object.defineProperty(Rectangle.prototype, "thickness", {
  8883. /** Gets or sets border thickness */
  8884. get: function () {
  8885. return this._thickness;
  8886. },
  8887. set: function (value) {
  8888. if (this._thickness === value) {
  8889. return;
  8890. }
  8891. this._thickness = value;
  8892. this._markAsDirty();
  8893. },
  8894. enumerable: true,
  8895. configurable: true
  8896. });
  8897. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8898. /** Gets or sets the corner radius angle */
  8899. get: function () {
  8900. return this._cornerRadius;
  8901. },
  8902. set: function (value) {
  8903. if (value < 0) {
  8904. value = 0;
  8905. }
  8906. if (this._cornerRadius === value) {
  8907. return;
  8908. }
  8909. this._cornerRadius = value;
  8910. this._markAsDirty();
  8911. },
  8912. enumerable: true,
  8913. configurable: true
  8914. });
  8915. Rectangle.prototype._getTypeName = function () {
  8916. return "Rectangle";
  8917. };
  8918. Rectangle.prototype._localDraw = function (context) {
  8919. context.save();
  8920. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8921. context.shadowColor = this.shadowColor;
  8922. context.shadowBlur = this.shadowBlur;
  8923. context.shadowOffsetX = this.shadowOffsetX;
  8924. context.shadowOffsetY = this.shadowOffsetY;
  8925. }
  8926. if (this._background) {
  8927. context.fillStyle = this._background;
  8928. if (this._cornerRadius) {
  8929. this._drawRoundedRect(context, this._thickness / 2);
  8930. context.fill();
  8931. }
  8932. else {
  8933. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8934. }
  8935. }
  8936. if (this._thickness) {
  8937. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8938. context.shadowBlur = 0;
  8939. context.shadowOffsetX = 0;
  8940. context.shadowOffsetY = 0;
  8941. }
  8942. if (this.color) {
  8943. context.strokeStyle = this.color;
  8944. }
  8945. context.lineWidth = this._thickness;
  8946. if (this._cornerRadius) {
  8947. this._drawRoundedRect(context, this._thickness / 2);
  8948. context.stroke();
  8949. }
  8950. else {
  8951. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8952. }
  8953. }
  8954. context.restore();
  8955. };
  8956. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8957. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8958. this._measureForChildren.width -= 2 * this._thickness;
  8959. this._measureForChildren.height -= 2 * this._thickness;
  8960. this._measureForChildren.left += this._thickness;
  8961. this._measureForChildren.top += this._thickness;
  8962. };
  8963. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8964. if (offset === void 0) { offset = 0; }
  8965. var x = this._currentMeasure.left + offset;
  8966. var y = this._currentMeasure.top + offset;
  8967. var width = this._currentMeasure.width - offset * 2;
  8968. var height = this._currentMeasure.height - offset * 2;
  8969. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8970. context.beginPath();
  8971. context.moveTo(x + radius, y);
  8972. context.lineTo(x + width - radius, y);
  8973. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8974. context.lineTo(x + width, y + height - radius);
  8975. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8976. context.lineTo(x + radius, y + height);
  8977. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8978. context.lineTo(x, y + radius);
  8979. context.quadraticCurveTo(x, y, x + radius, y);
  8980. context.closePath();
  8981. };
  8982. Rectangle.prototype._clipForChildren = function (context) {
  8983. if (this._cornerRadius) {
  8984. this._drawRoundedRect(context, this._thickness);
  8985. context.clip();
  8986. }
  8987. };
  8988. return Rectangle;
  8989. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8990. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8991. /***/ }),
  8992. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8993. /*!***************************************************!*\
  8994. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8995. \***************************************************/
  8996. /*! exports provided: ScrollViewer */
  8997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8998. "use strict";
  8999. __webpack_require__.r(__webpack_exports__);
  9000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9001. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9002. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9003. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9004. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9005. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9006. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9007. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9008. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  9009. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9010. /**
  9011. * Class used to hold a viewer window and sliders in a grid
  9012. */
  9013. var ScrollViewer = /** @class */ (function (_super) {
  9014. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9015. /**
  9016. * Creates a new ScrollViewer
  9017. * @param name of ScrollViewer
  9018. */
  9019. function ScrollViewer(name, isImageBased) {
  9020. var _this = _super.call(this, name) || this;
  9021. _this._barSize = 20;
  9022. _this._pointerIsOver = false;
  9023. _this._wheelPrecision = 0.05;
  9024. _this._thumbLength = 0.5;
  9025. _this._thumbHeight = 1;
  9026. _this._barImageHeight = 1;
  9027. _this._horizontalBarImageHeight = 1;
  9028. _this._verticalBarImageHeight = 1;
  9029. _this._oldWindowContentsWidth = 0;
  9030. _this._oldWindowContentsHeight = 0;
  9031. _this._forceHorizontalBar = false;
  9032. _this._forceVerticalBar = false;
  9033. _this._useImageBar = isImageBased ? isImageBased : false;
  9034. _this.onDirtyObservable.add(function () {
  9035. _this._horizontalBarSpace.color = _this.color;
  9036. _this._verticalBarSpace.color = _this.color;
  9037. _this._dragSpace.color = _this.color;
  9038. });
  9039. _this.onPointerEnterObservable.add(function () {
  9040. _this._pointerIsOver = true;
  9041. });
  9042. _this.onPointerOutObservable.add(function () {
  9043. _this._pointerIsOver = false;
  9044. });
  9045. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9046. if (_this._useImageBar) {
  9047. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9048. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9049. }
  9050. else {
  9051. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9052. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9053. }
  9054. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9055. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9056. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9057. _this._grid.addColumnDefinition(1);
  9058. _this._grid.addColumnDefinition(0, true);
  9059. _this._grid.addRowDefinition(1);
  9060. _this._grid.addRowDefinition(0, true);
  9061. _super.prototype.addControl.call(_this, _this._grid);
  9062. _this._grid.addControl(_this._window, 0, 0);
  9063. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9064. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9065. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9066. _this._verticalBarSpace.thickness = 1;
  9067. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9068. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9069. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9070. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9071. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9072. _this._horizontalBarSpace.thickness = 1;
  9073. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9074. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9075. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9076. _this._dragSpace.thickness = 1;
  9077. _this._grid.addControl(_this._dragSpace, 1, 1);
  9078. // Colors
  9079. if (!_this._useImageBar) {
  9080. _this.barColor = "grey";
  9081. _this.barBackground = "transparent";
  9082. }
  9083. return _this;
  9084. }
  9085. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9086. /**
  9087. * Gets the horizontal scrollbar
  9088. */
  9089. get: function () {
  9090. return this._horizontalBar;
  9091. },
  9092. enumerable: true,
  9093. configurable: true
  9094. });
  9095. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9096. /**
  9097. * Gets the vertical scrollbar
  9098. */
  9099. get: function () {
  9100. return this._verticalBar;
  9101. },
  9102. enumerable: true,
  9103. configurable: true
  9104. });
  9105. /**
  9106. * Adds a new control to the current container
  9107. * @param control defines the control to add
  9108. * @returns the current container
  9109. */
  9110. ScrollViewer.prototype.addControl = function (control) {
  9111. if (!control) {
  9112. return this;
  9113. }
  9114. this._window.addControl(control);
  9115. return this;
  9116. };
  9117. /**
  9118. * Removes a control from the current container
  9119. * @param control defines the control to remove
  9120. * @returns the current container
  9121. */
  9122. ScrollViewer.prototype.removeControl = function (control) {
  9123. this._window.removeControl(control);
  9124. return this;
  9125. };
  9126. Object.defineProperty(ScrollViewer.prototype, "children", {
  9127. /** Gets the list of children */
  9128. get: function () {
  9129. return this._window.children;
  9130. },
  9131. enumerable: true,
  9132. configurable: true
  9133. });
  9134. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9135. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9136. var child = _a[_i];
  9137. child._markMatrixAsDirty();
  9138. }
  9139. };
  9140. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9141. /**
  9142. * Freezes or unfreezes the controls in the window.
  9143. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9144. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9145. */
  9146. get: function () {
  9147. return this._window.freezeControls;
  9148. },
  9149. set: function (value) {
  9150. this._window.freezeControls = value;
  9151. },
  9152. enumerable: true,
  9153. configurable: true
  9154. });
  9155. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9156. /** Gets the bucket width */
  9157. get: function () {
  9158. return this._window.bucketWidth;
  9159. },
  9160. enumerable: true,
  9161. configurable: true
  9162. });
  9163. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9164. /** Gets the bucket height */
  9165. get: function () {
  9166. return this._window.bucketHeight;
  9167. },
  9168. enumerable: true,
  9169. configurable: true
  9170. });
  9171. /**
  9172. * Sets the bucket sizes.
  9173. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9174. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9175. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9176. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9177. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9178. * used), that's why it is not enabled by default.
  9179. * @param width width of the bucket
  9180. * @param height height of the bucket
  9181. */
  9182. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9183. this._window.setBucketSizes(width, height);
  9184. };
  9185. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9186. /**
  9187. * Forces the horizontal scroll bar to be displayed
  9188. */
  9189. get: function () {
  9190. return this._forceHorizontalBar;
  9191. },
  9192. set: function (value) {
  9193. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9194. this._horizontalBar.isVisible = value;
  9195. this._forceHorizontalBar = value;
  9196. },
  9197. enumerable: true,
  9198. configurable: true
  9199. });
  9200. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9201. /**
  9202. * Forces the vertical scroll bar to be displayed
  9203. */
  9204. get: function () {
  9205. return this._forceVerticalBar;
  9206. },
  9207. set: function (value) {
  9208. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9209. this._verticalBar.isVisible = value;
  9210. this._forceVerticalBar = value;
  9211. },
  9212. enumerable: true,
  9213. configurable: true
  9214. });
  9215. /** Reset the scroll viewer window to initial size */
  9216. ScrollViewer.prototype.resetWindow = function () {
  9217. this._window.width = "100%";
  9218. this._window.height = "100%";
  9219. };
  9220. ScrollViewer.prototype._getTypeName = function () {
  9221. return "ScrollViewer";
  9222. };
  9223. ScrollViewer.prototype._buildClientSizes = function () {
  9224. var ratio = this.host.idealRatio;
  9225. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9226. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9227. this._clientWidth = this._window.parentClientWidth;
  9228. this._clientHeight = this._window.parentClientHeight;
  9229. };
  9230. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9231. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9232. this._buildClientSizes();
  9233. };
  9234. ScrollViewer.prototype._postMeasure = function () {
  9235. _super.prototype._postMeasure.call(this);
  9236. this._updateScroller();
  9237. this._setWindowPosition(false);
  9238. };
  9239. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9240. /**
  9241. * Gets or sets the mouse wheel precision
  9242. * from 0 to 1 with a default value of 0.05
  9243. * */
  9244. get: function () {
  9245. return this._wheelPrecision;
  9246. },
  9247. set: function (value) {
  9248. if (this._wheelPrecision === value) {
  9249. return;
  9250. }
  9251. if (value < 0) {
  9252. value = 0;
  9253. }
  9254. if (value > 1) {
  9255. value = 1;
  9256. }
  9257. this._wheelPrecision = value;
  9258. },
  9259. enumerable: true,
  9260. configurable: true
  9261. });
  9262. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9263. /** Gets or sets the scroll bar container background color */
  9264. get: function () {
  9265. return this._horizontalBarSpace.background;
  9266. },
  9267. set: function (color) {
  9268. if (this._horizontalBarSpace.background === color) {
  9269. return;
  9270. }
  9271. this._horizontalBarSpace.background = color;
  9272. this._verticalBarSpace.background = color;
  9273. },
  9274. enumerable: true,
  9275. configurable: true
  9276. });
  9277. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9278. /** Gets or sets the bar color */
  9279. get: function () {
  9280. return this._barColor;
  9281. },
  9282. set: function (color) {
  9283. if (this._barColor === color) {
  9284. return;
  9285. }
  9286. this._barColor = color;
  9287. this._horizontalBar.color = color;
  9288. this._verticalBar.color = color;
  9289. },
  9290. enumerable: true,
  9291. configurable: true
  9292. });
  9293. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9294. /** Gets or sets the bar image */
  9295. get: function () {
  9296. return this._barImage;
  9297. },
  9298. set: function (value) {
  9299. if (this._barImage === value) {
  9300. return;
  9301. }
  9302. this._barImage = value;
  9303. var hb = this._horizontalBar;
  9304. var vb = this._verticalBar;
  9305. hb.thumbImage = value;
  9306. vb.thumbImage = value;
  9307. },
  9308. enumerable: true,
  9309. configurable: true
  9310. });
  9311. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9312. /** Gets or sets the horizontal bar image */
  9313. get: function () {
  9314. return this._horizontalBarImage;
  9315. },
  9316. set: function (value) {
  9317. if (this._horizontalBarImage === value) {
  9318. return;
  9319. }
  9320. this._horizontalBarImage = value;
  9321. var hb = this._horizontalBar;
  9322. hb.thumbImage = value;
  9323. },
  9324. enumerable: true,
  9325. configurable: true
  9326. });
  9327. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9328. /** Gets or sets the vertical bar image */
  9329. get: function () {
  9330. return this._verticalBarImage;
  9331. },
  9332. set: function (value) {
  9333. if (this._verticalBarImage === value) {
  9334. return;
  9335. }
  9336. this._verticalBarImage = value;
  9337. var vb = this._verticalBar;
  9338. vb.thumbImage = value;
  9339. },
  9340. enumerable: true,
  9341. configurable: true
  9342. });
  9343. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9344. /** Gets or sets the size of the bar */
  9345. get: function () {
  9346. return this._barSize;
  9347. },
  9348. set: function (value) {
  9349. if (this._barSize === value) {
  9350. return;
  9351. }
  9352. this._barSize = value;
  9353. this._markAsDirty();
  9354. if (this._horizontalBar.isVisible) {
  9355. this._grid.setRowDefinition(1, this._barSize, true);
  9356. }
  9357. if (this._verticalBar.isVisible) {
  9358. this._grid.setColumnDefinition(1, this._barSize, true);
  9359. }
  9360. },
  9361. enumerable: true,
  9362. configurable: true
  9363. });
  9364. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9365. /** Gets or sets the length of the thumb */
  9366. get: function () {
  9367. return this._thumbLength;
  9368. },
  9369. set: function (value) {
  9370. if (this._thumbLength === value) {
  9371. return;
  9372. }
  9373. if (value <= 0) {
  9374. value = 0.1;
  9375. }
  9376. if (value > 1) {
  9377. value = 1;
  9378. }
  9379. this._thumbLength = value;
  9380. var hb = this._horizontalBar;
  9381. var vb = this._verticalBar;
  9382. hb.thumbLength = value;
  9383. vb.thumbLength = value;
  9384. this._markAsDirty();
  9385. },
  9386. enumerable: true,
  9387. configurable: true
  9388. });
  9389. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9390. /** Gets or sets the height of the thumb */
  9391. get: function () {
  9392. return this._thumbHeight;
  9393. },
  9394. set: function (value) {
  9395. if (this._thumbHeight === value) {
  9396. return;
  9397. }
  9398. if (value <= 0) {
  9399. value = 0.1;
  9400. }
  9401. if (value > 1) {
  9402. value = 1;
  9403. }
  9404. this._thumbHeight = value;
  9405. var hb = this._horizontalBar;
  9406. var vb = this._verticalBar;
  9407. hb.thumbHeight = value;
  9408. vb.thumbHeight = value;
  9409. this._markAsDirty();
  9410. },
  9411. enumerable: true,
  9412. configurable: true
  9413. });
  9414. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9415. /** Gets or sets the height of the bar image */
  9416. get: function () {
  9417. return this._barImageHeight;
  9418. },
  9419. set: function (value) {
  9420. if (this._barImageHeight === value) {
  9421. return;
  9422. }
  9423. if (value <= 0) {
  9424. value = 0.1;
  9425. }
  9426. if (value > 1) {
  9427. value = 1;
  9428. }
  9429. this._barImageHeight = value;
  9430. var hb = this._horizontalBar;
  9431. var vb = this._verticalBar;
  9432. hb.barImageHeight = value;
  9433. vb.barImageHeight = value;
  9434. this._markAsDirty();
  9435. },
  9436. enumerable: true,
  9437. configurable: true
  9438. });
  9439. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9440. /** Gets or sets the height of the horizontal bar image */
  9441. get: function () {
  9442. return this._horizontalBarImageHeight;
  9443. },
  9444. set: function (value) {
  9445. if (this._horizontalBarImageHeight === value) {
  9446. return;
  9447. }
  9448. if (value <= 0) {
  9449. value = 0.1;
  9450. }
  9451. if (value > 1) {
  9452. value = 1;
  9453. }
  9454. this._horizontalBarImageHeight = value;
  9455. var hb = this._horizontalBar;
  9456. hb.barImageHeight = value;
  9457. this._markAsDirty();
  9458. },
  9459. enumerable: true,
  9460. configurable: true
  9461. });
  9462. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9463. /** Gets or sets the height of the vertical bar image */
  9464. get: function () {
  9465. return this._verticalBarImageHeight;
  9466. },
  9467. set: function (value) {
  9468. if (this._verticalBarImageHeight === value) {
  9469. return;
  9470. }
  9471. if (value <= 0) {
  9472. value = 0.1;
  9473. }
  9474. if (value > 1) {
  9475. value = 1;
  9476. }
  9477. this._verticalBarImageHeight = value;
  9478. var vb = this._verticalBar;
  9479. vb.barImageHeight = value;
  9480. this._markAsDirty();
  9481. },
  9482. enumerable: true,
  9483. configurable: true
  9484. });
  9485. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9486. /** Gets or sets the bar background */
  9487. get: function () {
  9488. return this._barBackground;
  9489. },
  9490. set: function (color) {
  9491. if (this._barBackground === color) {
  9492. return;
  9493. }
  9494. this._barBackground = color;
  9495. var hb = this._horizontalBar;
  9496. var vb = this._verticalBar;
  9497. hb.background = color;
  9498. vb.background = color;
  9499. this._dragSpace.background = color;
  9500. },
  9501. enumerable: true,
  9502. configurable: true
  9503. });
  9504. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9505. /** Gets or sets the bar background image */
  9506. get: function () {
  9507. return this._barBackgroundImage;
  9508. },
  9509. set: function (value) {
  9510. if (this._barBackgroundImage === value) {
  9511. }
  9512. this._barBackgroundImage = value;
  9513. var hb = this._horizontalBar;
  9514. var vb = this._verticalBar;
  9515. hb.backgroundImage = value;
  9516. vb.backgroundImage = value;
  9517. },
  9518. enumerable: true,
  9519. configurable: true
  9520. });
  9521. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9522. /** Gets or sets the horizontal bar background image */
  9523. get: function () {
  9524. return this._horizontalBarBackgroundImage;
  9525. },
  9526. set: function (value) {
  9527. if (this._horizontalBarBackgroundImage === value) {
  9528. }
  9529. this._horizontalBarBackgroundImage = value;
  9530. var hb = this._horizontalBar;
  9531. hb.backgroundImage = value;
  9532. },
  9533. enumerable: true,
  9534. configurable: true
  9535. });
  9536. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9537. /** Gets or sets the vertical bar background image */
  9538. get: function () {
  9539. return this._verticalBarBackgroundImage;
  9540. },
  9541. set: function (value) {
  9542. if (this._verticalBarBackgroundImage === value) {
  9543. }
  9544. this._verticalBarBackgroundImage = value;
  9545. var vb = this._verticalBar;
  9546. vb.backgroundImage = value;
  9547. },
  9548. enumerable: true,
  9549. configurable: true
  9550. });
  9551. ScrollViewer.prototype._setWindowPosition = function (force) {
  9552. if (force === void 0) { force = true; }
  9553. var ratio = this.host.idealRatio;
  9554. var windowContentsWidth = this._window._currentMeasure.width;
  9555. var windowContentsHeight = this._window._currentMeasure.height;
  9556. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9557. return;
  9558. }
  9559. this._oldWindowContentsWidth = windowContentsWidth;
  9560. this._oldWindowContentsHeight = windowContentsHeight;
  9561. var _endLeft = this._clientWidth - windowContentsWidth;
  9562. var _endTop = this._clientHeight - windowContentsHeight;
  9563. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9564. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9565. if (newLeft !== this._window.left) {
  9566. this._window.left = newLeft;
  9567. if (!this.freezeControls) {
  9568. this._rebuildLayout = true;
  9569. }
  9570. }
  9571. if (newTop !== this._window.top) {
  9572. this._window.top = newTop;
  9573. if (!this.freezeControls) {
  9574. this._rebuildLayout = true;
  9575. }
  9576. }
  9577. };
  9578. /** @hidden */
  9579. ScrollViewer.prototype._updateScroller = function () {
  9580. var windowContentsWidth = this._window._currentMeasure.width;
  9581. var windowContentsHeight = this._window._currentMeasure.height;
  9582. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9583. this._grid.setRowDefinition(1, 0, true);
  9584. this._horizontalBar.isVisible = false;
  9585. this._horizontalBar.value = 0;
  9586. this._rebuildLayout = true;
  9587. }
  9588. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9589. this._grid.setRowDefinition(1, this._barSize, true);
  9590. this._horizontalBar.isVisible = true;
  9591. this._rebuildLayout = true;
  9592. }
  9593. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9594. this._grid.setColumnDefinition(1, 0, true);
  9595. this._verticalBar.isVisible = false;
  9596. this._verticalBar.value = 0;
  9597. this._rebuildLayout = true;
  9598. }
  9599. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9600. this._grid.setColumnDefinition(1, this._barSize, true);
  9601. this._verticalBar.isVisible = true;
  9602. this._rebuildLayout = true;
  9603. }
  9604. this._buildClientSizes();
  9605. var ratio = this.host.idealRatio;
  9606. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9607. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9608. };
  9609. ScrollViewer.prototype._link = function (host) {
  9610. _super.prototype._link.call(this, host);
  9611. this._attachWheel();
  9612. };
  9613. /** @hidden */
  9614. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9615. var _this = this;
  9616. barControl.paddingLeft = 0;
  9617. barControl.width = "100%";
  9618. barControl.height = "100%";
  9619. barControl.barOffset = 0;
  9620. barControl.value = 0;
  9621. barControl.maximum = 1;
  9622. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9623. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9624. barControl.isVertical = isVertical;
  9625. barControl.rotation = rotation;
  9626. barControl.isVisible = false;
  9627. barContainer.addControl(barControl);
  9628. barControl.onValueChangedObservable.add(function (value) {
  9629. _this._setWindowPosition();
  9630. });
  9631. };
  9632. /** @hidden */
  9633. ScrollViewer.prototype._attachWheel = function () {
  9634. var _this = this;
  9635. if (!this._host || this._onWheelObserver) {
  9636. return;
  9637. }
  9638. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9639. if (!_this._pointerIsOver) {
  9640. return;
  9641. }
  9642. if (_this._verticalBar.isVisible == true) {
  9643. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9644. _this._verticalBar.value -= _this._wheelPrecision;
  9645. }
  9646. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9647. _this._verticalBar.value += _this._wheelPrecision;
  9648. }
  9649. }
  9650. if (_this._horizontalBar.isVisible == true) {
  9651. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9652. _this._horizontalBar.value += _this._wheelPrecision;
  9653. }
  9654. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9655. _this._horizontalBar.value -= _this._wheelPrecision;
  9656. }
  9657. }
  9658. });
  9659. };
  9660. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9661. if (!this.isHighlighted) {
  9662. return;
  9663. }
  9664. _super.prototype._renderHighlightSpecific.call(this, context);
  9665. this._grid._renderHighlightSpecific(context);
  9666. context.restore();
  9667. };
  9668. /** Releases associated resources */
  9669. ScrollViewer.prototype.dispose = function () {
  9670. this.onWheelObservable.remove(this._onWheelObserver);
  9671. this._onWheelObserver = null;
  9672. _super.prototype.dispose.call(this);
  9673. };
  9674. return ScrollViewer;
  9675. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9676. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9677. /***/ }),
  9678. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9679. /*!*********************************************************!*\
  9680. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9681. \*********************************************************/
  9682. /*! exports provided: _ScrollViewerWindow */
  9683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9684. "use strict";
  9685. __webpack_require__.r(__webpack_exports__);
  9686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9687. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9688. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9689. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9690. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9691. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9692. /**
  9693. * Class used to hold a the container for ScrollViewer
  9694. * @hidden
  9695. */
  9696. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9697. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9698. /**
  9699. * Creates a new ScrollViewerWindow
  9700. * @param name of ScrollViewerWindow
  9701. */
  9702. function _ScrollViewerWindow(name) {
  9703. var _this = _super.call(this, name) || this;
  9704. _this._freezeControls = false;
  9705. _this._bucketWidth = 0;
  9706. _this._bucketHeight = 0;
  9707. _this._buckets = {};
  9708. return _this;
  9709. }
  9710. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9711. get: function () {
  9712. return this._freezeControls;
  9713. },
  9714. set: function (value) {
  9715. if (this._freezeControls === value) {
  9716. return;
  9717. }
  9718. if (!value) {
  9719. this._restoreMeasures();
  9720. }
  9721. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9722. this._freezeControls = false;
  9723. var textureSize = this.host.getSize();
  9724. var renderWidth = textureSize.width;
  9725. var renderHeight = textureSize.height;
  9726. var context = this.host.getContext();
  9727. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9728. this.host._numLayoutCalls = 0;
  9729. this.host._rootContainer._layout(measure, context);
  9730. // in freeze mode, prepare children measures accordingly
  9731. if (value) {
  9732. this._updateMeasures();
  9733. if (this._useBuckets()) {
  9734. this._makeBuckets();
  9735. }
  9736. }
  9737. this._freezeControls = value;
  9738. this.host.markAsDirty(); // redraw with the (new) current settings
  9739. },
  9740. enumerable: true,
  9741. configurable: true
  9742. });
  9743. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9744. get: function () {
  9745. return this._bucketWidth;
  9746. },
  9747. enumerable: true,
  9748. configurable: true
  9749. });
  9750. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9751. get: function () {
  9752. return this._bucketHeight;
  9753. },
  9754. enumerable: true,
  9755. configurable: true
  9756. });
  9757. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9758. this._bucketWidth = width;
  9759. this._bucketHeight = height;
  9760. if (this._useBuckets()) {
  9761. if (this._freezeControls) {
  9762. this._makeBuckets();
  9763. }
  9764. }
  9765. else {
  9766. this._buckets = {};
  9767. }
  9768. };
  9769. _ScrollViewerWindow.prototype._useBuckets = function () {
  9770. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9771. };
  9772. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9773. this._buckets = {};
  9774. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9775. this._dispatchInBuckets(this._children);
  9776. this._oldLeft = null;
  9777. this._oldTop = null;
  9778. };
  9779. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9780. for (var i = 0; i < children.length; ++i) {
  9781. var child = children[i];
  9782. var bStartX = Math.max(0, Math.floor((child._customData._origLeft - this._customData.origLeft) / this._bucketWidth)), bEndX = Math.floor((child._customData._origLeft - this._customData.origLeft + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._customData._origTop - this._customData.origTop) / this._bucketHeight)), bEndY = Math.floor((child._customData._origTop - this._customData.origTop + child._currentMeasure.height - 1) / this._bucketHeight);
  9783. while (bStartY <= bEndY) {
  9784. for (var x = bStartX; x <= bEndX; ++x) {
  9785. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9786. if (!lstc) {
  9787. lstc = [];
  9788. this._buckets[bucket] = lstc;
  9789. }
  9790. lstc.push(child);
  9791. }
  9792. bStartY++;
  9793. }
  9794. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9795. this._dispatchInBuckets(child._children);
  9796. }
  9797. }
  9798. };
  9799. // reset left and top measures for the window and all its children
  9800. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9801. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9802. this._measureForChildren.left -= left;
  9803. this._measureForChildren.top -= top;
  9804. this._currentMeasure.left -= left;
  9805. this._currentMeasure.top -= top;
  9806. this._customData.origLeftForChildren = this._measureForChildren.left;
  9807. this._customData.origTopForChildren = this._measureForChildren.top;
  9808. this._customData.origLeft = this._currentMeasure.left;
  9809. this._customData.origTop = this._currentMeasure.top;
  9810. this._updateChildrenMeasures(this._children, left, top);
  9811. };
  9812. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9813. for (var i = 0; i < children.length; ++i) {
  9814. var child = children[i];
  9815. child._currentMeasure.left -= left;
  9816. child._currentMeasure.top -= top;
  9817. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9818. child._customData._origTop = child._currentMeasure.top;
  9819. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9820. this._updateChildrenMeasures(child._children, left, top);
  9821. }
  9822. }
  9823. };
  9824. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  9825. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9826. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  9827. this._measureForChildren.top = this._customData.origTopForChildren + top;
  9828. this._currentMeasure.left = this._customData.origLeft + left;
  9829. this._currentMeasure.top = this._customData.origTop + top;
  9830. };
  9831. _ScrollViewerWindow.prototype._getTypeName = function () {
  9832. return "ScrollViewerWindow";
  9833. };
  9834. /** @hidden */
  9835. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9836. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9837. this._parentMeasure = parentMeasure;
  9838. this._measureForChildren.left = this._currentMeasure.left;
  9839. this._measureForChildren.top = this._currentMeasure.top;
  9840. this._measureForChildren.width = parentMeasure.width;
  9841. this._measureForChildren.height = parentMeasure.height;
  9842. };
  9843. /** @hidden */
  9844. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9845. if (this._freezeControls) {
  9846. this.invalidateRect(); // will trigger a redraw of the window
  9847. return false;
  9848. }
  9849. return _super.prototype._layout.call(this, parentMeasure, context);
  9850. };
  9851. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9852. for (var i = 0; i < children.length; ++i) {
  9853. var child = children[i];
  9854. child._currentMeasure.left = child._customData._origLeft + left;
  9855. child._currentMeasure.top = child._customData._origTop + top;
  9856. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9857. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9858. this._scrollChildren(child._children, left, top);
  9859. }
  9860. }
  9861. };
  9862. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9863. var bStartX = Math.max(0, Math.floor(-left / this._bucketWidth)), bEndX = Math.floor((-left + this._parentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor(-top / this._bucketHeight)), bEndY = Math.floor((-top + this._parentMeasure.height - 1) / this._bucketHeight);
  9864. while (bStartY <= bEndY) {
  9865. for (var x = bStartX; x <= bEndX; ++x) {
  9866. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9867. if (lstc) {
  9868. for (var i = 0; i < lstc.length; ++i) {
  9869. var child = lstc[i];
  9870. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9871. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9872. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9873. }
  9874. }
  9875. }
  9876. bStartY++;
  9877. }
  9878. };
  9879. /** @hidden */
  9880. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9881. if (!this._freezeControls) {
  9882. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9883. return;
  9884. }
  9885. this._localDraw(context);
  9886. if (this.clipChildren) {
  9887. this._clipForChildren(context);
  9888. }
  9889. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9890. if (this._useBuckets()) {
  9891. if (this._oldLeft !== null && this._oldTop !== null) {
  9892. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9893. this._scrollChildrenWithBuckets(left, top, left, top);
  9894. }
  9895. else {
  9896. this._scrollChildren(this._children, left, top);
  9897. }
  9898. }
  9899. else {
  9900. this._scrollChildren(this._children, left, top);
  9901. }
  9902. this._oldLeft = left;
  9903. this._oldTop = top;
  9904. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9905. var child = _a[_i];
  9906. if (!child._intersectsRect(this._parentMeasure)) {
  9907. continue;
  9908. }
  9909. child._render(context, this._parentMeasure);
  9910. }
  9911. };
  9912. _ScrollViewerWindow.prototype._postMeasure = function () {
  9913. if (this._freezeControls) {
  9914. _super.prototype._postMeasure.call(this);
  9915. return;
  9916. }
  9917. var maxWidth = this.parentClientWidth;
  9918. var maxHeight = this.parentClientHeight;
  9919. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9920. var child = _a[_i];
  9921. if (!child.isVisible || child.notRenderable) {
  9922. continue;
  9923. }
  9924. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9925. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9926. }
  9927. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9928. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9929. }
  9930. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9931. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9932. }
  9933. if (this._currentMeasure.width !== maxWidth) {
  9934. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9935. this._currentMeasure.width = maxWidth;
  9936. this._rebuildLayout = true;
  9937. this._isDirty = true;
  9938. }
  9939. if (this._currentMeasure.height !== maxHeight) {
  9940. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9941. this._currentMeasure.height = maxHeight;
  9942. this._rebuildLayout = true;
  9943. this._isDirty = true;
  9944. }
  9945. _super.prototype._postMeasure.call(this);
  9946. };
  9947. return _ScrollViewerWindow;
  9948. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9949. /***/ }),
  9950. /***/ "./2D/controls/selector.ts":
  9951. /*!*********************************!*\
  9952. !*** ./2D/controls/selector.ts ***!
  9953. \*********************************/
  9954. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9956. "use strict";
  9957. __webpack_require__.r(__webpack_exports__);
  9958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9963. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9964. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9965. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9966. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9967. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9968. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9969. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9970. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9971. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9972. /** Class used to create a RadioGroup
  9973. * which contains groups of radio buttons
  9974. */
  9975. var SelectorGroup = /** @class */ (function () {
  9976. /**
  9977. * Creates a new SelectorGroup
  9978. * @param name of group, used as a group heading
  9979. */
  9980. function SelectorGroup(
  9981. /** name of SelectorGroup */
  9982. name) {
  9983. this.name = name;
  9984. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9985. this._selectors = new Array();
  9986. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9987. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9988. this._groupHeader = this._addGroupHeader(name);
  9989. }
  9990. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9991. /** Gets the groupPanel of the SelectorGroup */
  9992. get: function () {
  9993. return this._groupPanel;
  9994. },
  9995. enumerable: true,
  9996. configurable: true
  9997. });
  9998. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9999. /** Gets the selectors array */
  10000. get: function () {
  10001. return this._selectors;
  10002. },
  10003. enumerable: true,
  10004. configurable: true
  10005. });
  10006. Object.defineProperty(SelectorGroup.prototype, "header", {
  10007. /** Gets and sets the group header */
  10008. get: function () {
  10009. return this._groupHeader.text;
  10010. },
  10011. set: function (label) {
  10012. if (this._groupHeader.text === "label") {
  10013. return;
  10014. }
  10015. this._groupHeader.text = label;
  10016. },
  10017. enumerable: true,
  10018. configurable: true
  10019. });
  10020. /** @hidden */
  10021. SelectorGroup.prototype._addGroupHeader = function (text) {
  10022. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10023. groupHeading.width = 0.9;
  10024. groupHeading.height = "30px";
  10025. groupHeading.textWrapping = true;
  10026. groupHeading.color = "black";
  10027. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10028. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10029. groupHeading.left = "2px";
  10030. this._groupPanel.addControl(groupHeading);
  10031. return groupHeading;
  10032. };
  10033. /** @hidden*/
  10034. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10035. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10036. return;
  10037. }
  10038. return this._selectors[selectorNb];
  10039. };
  10040. /** Removes the selector at the given position
  10041. * @param selectorNb the position of the selector within the group
  10042. */
  10043. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10044. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10045. return;
  10046. }
  10047. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10048. this._selectors.splice(selectorNb, 1);
  10049. };
  10050. return SelectorGroup;
  10051. }());
  10052. /** Class used to create a CheckboxGroup
  10053. * which contains groups of checkbox buttons
  10054. */
  10055. var CheckboxGroup = /** @class */ (function (_super) {
  10056. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10057. function CheckboxGroup() {
  10058. return _super !== null && _super.apply(this, arguments) || this;
  10059. }
  10060. /** Adds a checkbox as a control
  10061. * @param text is the label for the selector
  10062. * @param func is the function called when the Selector is checked
  10063. * @param checked is true when Selector is checked
  10064. */
  10065. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10066. if (func === void 0) { func = function (s) { }; }
  10067. if (checked === void 0) { checked = false; }
  10068. var checked = checked || false;
  10069. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10070. button.width = "20px";
  10071. button.height = "20px";
  10072. button.color = "#364249";
  10073. button.background = "#CCCCCC";
  10074. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10075. button.onIsCheckedChangedObservable.add(function (state) {
  10076. func(state);
  10077. });
  10078. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10079. _selector.height = "30px";
  10080. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10081. _selector.left = "4px";
  10082. this.groupPanel.addControl(_selector);
  10083. this.selectors.push(_selector);
  10084. button.isChecked = checked;
  10085. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10086. button.color = this.groupPanel.parent.parent.buttonColor;
  10087. button.background = this.groupPanel.parent.parent.buttonBackground;
  10088. }
  10089. };
  10090. /** @hidden */
  10091. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10092. this.selectors[selectorNb].children[1].text = label;
  10093. };
  10094. /** @hidden */
  10095. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10096. this.selectors[selectorNb].children[1].color = color;
  10097. };
  10098. /** @hidden */
  10099. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10100. this.selectors[selectorNb].children[0].color = color;
  10101. };
  10102. /** @hidden */
  10103. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10104. this.selectors[selectorNb].children[0].background = color;
  10105. };
  10106. return CheckboxGroup;
  10107. }(SelectorGroup));
  10108. /** Class used to create a RadioGroup
  10109. * which contains groups of radio buttons
  10110. */
  10111. var RadioGroup = /** @class */ (function (_super) {
  10112. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10113. function RadioGroup() {
  10114. var _this = _super !== null && _super.apply(this, arguments) || this;
  10115. _this._selectNb = 0;
  10116. return _this;
  10117. }
  10118. /** Adds a radio button as a control
  10119. * @param label is the label for the selector
  10120. * @param func is the function called when the Selector is checked
  10121. * @param checked is true when Selector is checked
  10122. */
  10123. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10124. if (func === void 0) { func = function (n) { }; }
  10125. if (checked === void 0) { checked = false; }
  10126. var nb = this._selectNb++;
  10127. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10128. button.name = label;
  10129. button.width = "20px";
  10130. button.height = "20px";
  10131. button.color = "#364249";
  10132. button.background = "#CCCCCC";
  10133. button.group = this.name;
  10134. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10135. button.onIsCheckedChangedObservable.add(function (state) {
  10136. if (state) {
  10137. func(nb);
  10138. }
  10139. });
  10140. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10141. _selector.height = "30px";
  10142. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10143. _selector.left = "4px";
  10144. this.groupPanel.addControl(_selector);
  10145. this.selectors.push(_selector);
  10146. button.isChecked = checked;
  10147. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10148. button.color = this.groupPanel.parent.parent.buttonColor;
  10149. button.background = this.groupPanel.parent.parent.buttonBackground;
  10150. }
  10151. };
  10152. /** @hidden */
  10153. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10154. this.selectors[selectorNb].children[1].text = label;
  10155. };
  10156. /** @hidden */
  10157. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10158. this.selectors[selectorNb].children[1].color = color;
  10159. };
  10160. /** @hidden */
  10161. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10162. this.selectors[selectorNb].children[0].color = color;
  10163. };
  10164. /** @hidden */
  10165. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10166. this.selectors[selectorNb].children[0].background = color;
  10167. };
  10168. return RadioGroup;
  10169. }(SelectorGroup));
  10170. /** Class used to create a SliderGroup
  10171. * which contains groups of slider buttons
  10172. */
  10173. var SliderGroup = /** @class */ (function (_super) {
  10174. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10175. function SliderGroup() {
  10176. return _super !== null && _super.apply(this, arguments) || this;
  10177. }
  10178. /**
  10179. * Adds a slider to the SelectorGroup
  10180. * @param label is the label for the SliderBar
  10181. * @param func is the function called when the Slider moves
  10182. * @param unit is a string describing the units used, eg degrees or metres
  10183. * @param min is the minimum value for the Slider
  10184. * @param max is the maximum value for the Slider
  10185. * @param value is the start value for the Slider between min and max
  10186. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10187. */
  10188. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10189. if (func === void 0) { func = function (v) { }; }
  10190. if (unit === void 0) { unit = "Units"; }
  10191. if (min === void 0) { min = 0; }
  10192. if (max === void 0) { max = 0; }
  10193. if (value === void 0) { value = 0; }
  10194. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10195. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10196. button.name = unit;
  10197. button.value = value;
  10198. button.minimum = min;
  10199. button.maximum = max;
  10200. button.width = 0.9;
  10201. button.height = "20px";
  10202. button.color = "#364249";
  10203. button.background = "#CCCCCC";
  10204. button.borderColor = "black";
  10205. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10206. button.left = "4px";
  10207. button.paddingBottom = "4px";
  10208. button.onValueChangedObservable.add(function (value) {
  10209. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10210. func(value);
  10211. });
  10212. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10213. _selector.height = "60px";
  10214. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10215. _selector.left = "4px";
  10216. _selector.children[0].name = label;
  10217. this.groupPanel.addControl(_selector);
  10218. this.selectors.push(_selector);
  10219. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10220. button.color = this.groupPanel.parent.parent.buttonColor;
  10221. button.background = this.groupPanel.parent.parent.buttonBackground;
  10222. }
  10223. };
  10224. /** @hidden */
  10225. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10226. this.selectors[selectorNb].children[0].name = label;
  10227. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10228. };
  10229. /** @hidden */
  10230. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10231. this.selectors[selectorNb].children[0].color = color;
  10232. };
  10233. /** @hidden */
  10234. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10235. this.selectors[selectorNb].children[1].color = color;
  10236. };
  10237. /** @hidden */
  10238. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10239. this.selectors[selectorNb].children[1].background = color;
  10240. };
  10241. return SliderGroup;
  10242. }(SelectorGroup));
  10243. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10244. * @see http://doc.babylonjs.com/how_to/selector
  10245. */
  10246. var SelectionPanel = /** @class */ (function (_super) {
  10247. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10248. /**
  10249. * Creates a new SelectionPanel
  10250. * @param name of SelectionPanel
  10251. * @param groups is an array of SelectionGroups
  10252. */
  10253. function SelectionPanel(
  10254. /** name of SelectionPanel */
  10255. name,
  10256. /** an array of SelectionGroups */
  10257. groups) {
  10258. if (groups === void 0) { groups = []; }
  10259. var _this = _super.call(this, name) || this;
  10260. _this.name = name;
  10261. _this.groups = groups;
  10262. _this._buttonColor = "#364249";
  10263. _this._buttonBackground = "#CCCCCC";
  10264. _this._headerColor = "black";
  10265. _this._barColor = "white";
  10266. _this._barHeight = "2px";
  10267. _this._spacerHeight = "20px";
  10268. _this._bars = new Array();
  10269. _this._groups = groups;
  10270. _this.thickness = 2;
  10271. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10272. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10273. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10274. _this._panel.top = 5;
  10275. _this._panel.left = 5;
  10276. _this._panel.width = 0.95;
  10277. if (groups.length > 0) {
  10278. for (var i = 0; i < groups.length - 1; i++) {
  10279. _this._panel.addControl(groups[i].groupPanel);
  10280. _this._addSpacer();
  10281. }
  10282. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10283. }
  10284. _this.addControl(_this._panel);
  10285. return _this;
  10286. }
  10287. SelectionPanel.prototype._getTypeName = function () {
  10288. return "SelectionPanel";
  10289. };
  10290. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10291. /** Gets or sets the headerColor */
  10292. get: function () {
  10293. return this._headerColor;
  10294. },
  10295. set: function (color) {
  10296. if (this._headerColor === color) {
  10297. return;
  10298. }
  10299. this._headerColor = color;
  10300. this._setHeaderColor();
  10301. },
  10302. enumerable: true,
  10303. configurable: true
  10304. });
  10305. SelectionPanel.prototype._setHeaderColor = function () {
  10306. for (var i = 0; i < this._groups.length; i++) {
  10307. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10308. }
  10309. };
  10310. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10311. /** Gets or sets the button color */
  10312. get: function () {
  10313. return this._buttonColor;
  10314. },
  10315. set: function (color) {
  10316. if (this._buttonColor === color) {
  10317. return;
  10318. }
  10319. this._buttonColor = color;
  10320. this._setbuttonColor();
  10321. },
  10322. enumerable: true,
  10323. configurable: true
  10324. });
  10325. SelectionPanel.prototype._setbuttonColor = function () {
  10326. for (var i = 0; i < this._groups.length; i++) {
  10327. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10328. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10329. }
  10330. }
  10331. };
  10332. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10333. /** Gets or sets the label color */
  10334. get: function () {
  10335. return this._labelColor;
  10336. },
  10337. set: function (color) {
  10338. if (this._labelColor === color) {
  10339. return;
  10340. }
  10341. this._labelColor = color;
  10342. this._setLabelColor();
  10343. },
  10344. enumerable: true,
  10345. configurable: true
  10346. });
  10347. SelectionPanel.prototype._setLabelColor = function () {
  10348. for (var i = 0; i < this._groups.length; i++) {
  10349. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10350. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10351. }
  10352. }
  10353. };
  10354. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10355. /** Gets or sets the button background */
  10356. get: function () {
  10357. return this._buttonBackground;
  10358. },
  10359. set: function (color) {
  10360. if (this._buttonBackground === color) {
  10361. return;
  10362. }
  10363. this._buttonBackground = color;
  10364. this._setButtonBackground();
  10365. },
  10366. enumerable: true,
  10367. configurable: true
  10368. });
  10369. SelectionPanel.prototype._setButtonBackground = function () {
  10370. for (var i = 0; i < this._groups.length; i++) {
  10371. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10372. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10373. }
  10374. }
  10375. };
  10376. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10377. /** Gets or sets the color of separator bar */
  10378. get: function () {
  10379. return this._barColor;
  10380. },
  10381. set: function (color) {
  10382. if (this._barColor === color) {
  10383. return;
  10384. }
  10385. this._barColor = color;
  10386. this._setBarColor();
  10387. },
  10388. enumerable: true,
  10389. configurable: true
  10390. });
  10391. SelectionPanel.prototype._setBarColor = function () {
  10392. for (var i = 0; i < this._bars.length; i++) {
  10393. this._bars[i].children[0].background = this._barColor;
  10394. }
  10395. };
  10396. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10397. /** Gets or sets the height of separator bar */
  10398. get: function () {
  10399. return this._barHeight;
  10400. },
  10401. set: function (value) {
  10402. if (this._barHeight === value) {
  10403. return;
  10404. }
  10405. this._barHeight = value;
  10406. this._setBarHeight();
  10407. },
  10408. enumerable: true,
  10409. configurable: true
  10410. });
  10411. SelectionPanel.prototype._setBarHeight = function () {
  10412. for (var i = 0; i < this._bars.length; i++) {
  10413. this._bars[i].children[0].height = this._barHeight;
  10414. }
  10415. };
  10416. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10417. /** Gets or sets the height of spacers*/
  10418. get: function () {
  10419. return this._spacerHeight;
  10420. },
  10421. set: function (value) {
  10422. if (this._spacerHeight === value) {
  10423. return;
  10424. }
  10425. this._spacerHeight = value;
  10426. this._setSpacerHeight();
  10427. },
  10428. enumerable: true,
  10429. configurable: true
  10430. });
  10431. SelectionPanel.prototype._setSpacerHeight = function () {
  10432. for (var i = 0; i < this._bars.length; i++) {
  10433. this._bars[i].height = this._spacerHeight;
  10434. }
  10435. };
  10436. /** Adds a bar between groups */
  10437. SelectionPanel.prototype._addSpacer = function () {
  10438. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10439. separator.width = 1;
  10440. separator.height = this._spacerHeight;
  10441. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10442. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10443. bar.width = 1;
  10444. bar.height = this._barHeight;
  10445. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10446. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10447. bar.background = this._barColor;
  10448. bar.color = "transparent";
  10449. separator.addControl(bar);
  10450. this._panel.addControl(separator);
  10451. this._bars.push(separator);
  10452. };
  10453. /** Add a group to the selection panel
  10454. * @param group is the selector group to add
  10455. */
  10456. SelectionPanel.prototype.addGroup = function (group) {
  10457. if (this._groups.length > 0) {
  10458. this._addSpacer();
  10459. }
  10460. this._panel.addControl(group.groupPanel);
  10461. this._groups.push(group);
  10462. group.groupPanel.children[0].color = this._headerColor;
  10463. for (var j = 0; j < group.selectors.length; j++) {
  10464. group._setSelectorButtonColor(j, this._buttonColor);
  10465. group._setSelectorButtonBackground(j, this._buttonBackground);
  10466. }
  10467. };
  10468. /** Remove the group from the given position
  10469. * @param groupNb is the position of the group in the list
  10470. */
  10471. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10472. if (groupNb < 0 || groupNb >= this._groups.length) {
  10473. return;
  10474. }
  10475. var group = this._groups[groupNb];
  10476. this._panel.removeControl(group.groupPanel);
  10477. this._groups.splice(groupNb, 1);
  10478. if (groupNb < this._bars.length) {
  10479. this._panel.removeControl(this._bars[groupNb]);
  10480. this._bars.splice(groupNb, 1);
  10481. }
  10482. };
  10483. /** Change a group header label
  10484. * @param label is the new group header label
  10485. * @param groupNb is the number of the group to relabel
  10486. * */
  10487. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10488. if (groupNb < 0 || groupNb >= this._groups.length) {
  10489. return;
  10490. }
  10491. var group = this._groups[groupNb];
  10492. group.groupPanel.children[0].text = label;
  10493. };
  10494. /** Change selector label to the one given
  10495. * @param label is the new selector label
  10496. * @param groupNb is the number of the groupcontaining the selector
  10497. * @param selectorNb is the number of the selector within a group to relabel
  10498. * */
  10499. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10500. if (groupNb < 0 || groupNb >= this._groups.length) {
  10501. return;
  10502. }
  10503. var group = this._groups[groupNb];
  10504. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10505. return;
  10506. }
  10507. group._setSelectorLabel(selectorNb, label);
  10508. };
  10509. /** For a given group position remove the selector at the given position
  10510. * @param groupNb is the number of the group to remove the selector from
  10511. * @param selectorNb is the number of the selector within the group
  10512. */
  10513. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10514. if (groupNb < 0 || groupNb >= this._groups.length) {
  10515. return;
  10516. }
  10517. var group = this._groups[groupNb];
  10518. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10519. return;
  10520. }
  10521. group.removeSelector(selectorNb);
  10522. };
  10523. /** For a given group position of correct type add a checkbox button
  10524. * @param groupNb is the number of the group to remove the selector from
  10525. * @param label is the label for the selector
  10526. * @param func is the function called when the Selector is checked
  10527. * @param checked is true when Selector is checked
  10528. */
  10529. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10530. if (func === void 0) { func = function () { }; }
  10531. if (checked === void 0) { checked = false; }
  10532. if (groupNb < 0 || groupNb >= this._groups.length) {
  10533. return;
  10534. }
  10535. var group = this._groups[groupNb];
  10536. group.addCheckbox(label, func, checked);
  10537. };
  10538. /** For a given group position of correct type add a radio button
  10539. * @param groupNb is the number of the group to remove the selector from
  10540. * @param label is the label for the selector
  10541. * @param func is the function called when the Selector is checked
  10542. * @param checked is true when Selector is checked
  10543. */
  10544. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10545. if (func === void 0) { func = function () { }; }
  10546. if (checked === void 0) { checked = false; }
  10547. if (groupNb < 0 || groupNb >= this._groups.length) {
  10548. return;
  10549. }
  10550. var group = this._groups[groupNb];
  10551. group.addRadio(label, func, checked);
  10552. };
  10553. /**
  10554. * For a given slider group add a slider
  10555. * @param groupNb is the number of the group to add the slider to
  10556. * @param label is the label for the Slider
  10557. * @param func is the function called when the Slider moves
  10558. * @param unit is a string describing the units used, eg degrees or metres
  10559. * @param min is the minimum value for the Slider
  10560. * @param max is the maximum value for the Slider
  10561. * @param value is the start value for the Slider between min and max
  10562. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10563. */
  10564. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10565. if (func === void 0) { func = function () { }; }
  10566. if (unit === void 0) { unit = "Units"; }
  10567. if (min === void 0) { min = 0; }
  10568. if (max === void 0) { max = 0; }
  10569. if (value === void 0) { value = 0; }
  10570. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10571. if (groupNb < 0 || groupNb >= this._groups.length) {
  10572. return;
  10573. }
  10574. var group = this._groups[groupNb];
  10575. group.addSlider(label, func, unit, min, max, value, onVal);
  10576. };
  10577. return SelectionPanel;
  10578. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10579. /***/ }),
  10580. /***/ "./2D/controls/sliders/baseSlider.ts":
  10581. /*!*******************************************!*\
  10582. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10583. \*******************************************/
  10584. /*! exports provided: BaseSlider */
  10585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10586. "use strict";
  10587. __webpack_require__.r(__webpack_exports__);
  10588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10590. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  10591. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10592. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10593. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10594. /**
  10595. * Class used to create slider controls
  10596. */
  10597. var BaseSlider = /** @class */ (function (_super) {
  10598. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10599. /**
  10600. * Creates a new BaseSlider
  10601. * @param name defines the control name
  10602. */
  10603. function BaseSlider(name) {
  10604. var _this = _super.call(this, name) || this;
  10605. _this.name = name;
  10606. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10607. _this._minimum = 0;
  10608. _this._maximum = 100;
  10609. _this._value = 50;
  10610. _this._isVertical = false;
  10611. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10612. _this._isThumbClamped = false;
  10613. _this._displayThumb = true;
  10614. _this._step = 0;
  10615. _this._lastPointerDownID = -1;
  10616. // Shared rendering info
  10617. _this._effectiveBarOffset = 0;
  10618. /** Observable raised when the sldier value changes */
  10619. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10620. // Events
  10621. _this._pointerIsDown = false;
  10622. _this.isPointerBlocker = true;
  10623. return _this;
  10624. }
  10625. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10626. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10627. get: function () {
  10628. return this._displayThumb;
  10629. },
  10630. set: function (value) {
  10631. if (this._displayThumb === value) {
  10632. return;
  10633. }
  10634. this._displayThumb = value;
  10635. this._markAsDirty();
  10636. },
  10637. enumerable: true,
  10638. configurable: true
  10639. });
  10640. Object.defineProperty(BaseSlider.prototype, "step", {
  10641. /** Gets or sets a step to apply to values (0 by default) */
  10642. get: function () {
  10643. return this._step;
  10644. },
  10645. set: function (value) {
  10646. if (this._step === value) {
  10647. return;
  10648. }
  10649. this._step = value;
  10650. this._markAsDirty();
  10651. },
  10652. enumerable: true,
  10653. configurable: true
  10654. });
  10655. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10656. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10657. get: function () {
  10658. return this._barOffset.toString(this._host);
  10659. },
  10660. set: function (value) {
  10661. if (this._barOffset.toString(this._host) === value) {
  10662. return;
  10663. }
  10664. if (this._barOffset.fromString(value)) {
  10665. this._markAsDirty();
  10666. }
  10667. },
  10668. enumerable: true,
  10669. configurable: true
  10670. });
  10671. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10672. /** Gets main bar offset in pixels*/
  10673. get: function () {
  10674. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10675. },
  10676. enumerable: true,
  10677. configurable: true
  10678. });
  10679. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10680. /** Gets or sets thumb width */
  10681. get: function () {
  10682. return this._thumbWidth.toString(this._host);
  10683. },
  10684. set: function (value) {
  10685. if (this._thumbWidth.toString(this._host) === value) {
  10686. return;
  10687. }
  10688. if (this._thumbWidth.fromString(value)) {
  10689. this._markAsDirty();
  10690. }
  10691. },
  10692. enumerable: true,
  10693. configurable: true
  10694. });
  10695. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10696. /** Gets thumb width in pixels */
  10697. get: function () {
  10698. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10699. },
  10700. enumerable: true,
  10701. configurable: true
  10702. });
  10703. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10704. /** Gets or sets minimum value */
  10705. get: function () {
  10706. return this._minimum;
  10707. },
  10708. set: function (value) {
  10709. if (this._minimum === value) {
  10710. return;
  10711. }
  10712. this._minimum = value;
  10713. this._markAsDirty();
  10714. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10715. },
  10716. enumerable: true,
  10717. configurable: true
  10718. });
  10719. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10720. /** Gets or sets maximum value */
  10721. get: function () {
  10722. return this._maximum;
  10723. },
  10724. set: function (value) {
  10725. if (this._maximum === value) {
  10726. return;
  10727. }
  10728. this._maximum = value;
  10729. this._markAsDirty();
  10730. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10731. },
  10732. enumerable: true,
  10733. configurable: true
  10734. });
  10735. Object.defineProperty(BaseSlider.prototype, "value", {
  10736. /** Gets or sets current value */
  10737. get: function () {
  10738. return this._value;
  10739. },
  10740. set: function (value) {
  10741. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10742. if (this._value === value) {
  10743. return;
  10744. }
  10745. this._value = value;
  10746. this._markAsDirty();
  10747. this.onValueChangedObservable.notifyObservers(this._value);
  10748. },
  10749. enumerable: true,
  10750. configurable: true
  10751. });
  10752. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10753. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10754. get: function () {
  10755. return this._isVertical;
  10756. },
  10757. set: function (value) {
  10758. if (this._isVertical === value) {
  10759. return;
  10760. }
  10761. this._isVertical = value;
  10762. this._markAsDirty();
  10763. },
  10764. enumerable: true,
  10765. configurable: true
  10766. });
  10767. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10768. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10769. get: function () {
  10770. return this._isThumbClamped;
  10771. },
  10772. set: function (value) {
  10773. if (this._isThumbClamped === value) {
  10774. return;
  10775. }
  10776. this._isThumbClamped = value;
  10777. this._markAsDirty();
  10778. },
  10779. enumerable: true,
  10780. configurable: true
  10781. });
  10782. BaseSlider.prototype._getTypeName = function () {
  10783. return "BaseSlider";
  10784. };
  10785. BaseSlider.prototype._getThumbPosition = function () {
  10786. if (this.isVertical) {
  10787. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10788. }
  10789. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10790. };
  10791. BaseSlider.prototype._getThumbThickness = function (type) {
  10792. var thumbThickness = 0;
  10793. switch (type) {
  10794. case "circle":
  10795. if (this._thumbWidth.isPixel) {
  10796. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10797. }
  10798. else {
  10799. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10800. }
  10801. break;
  10802. case "rectangle":
  10803. if (this._thumbWidth.isPixel) {
  10804. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10805. }
  10806. else {
  10807. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10808. }
  10809. }
  10810. return thumbThickness;
  10811. };
  10812. BaseSlider.prototype._prepareRenderingData = function (type) {
  10813. // Main bar
  10814. this._effectiveBarOffset = 0;
  10815. this._renderLeft = this._currentMeasure.left;
  10816. this._renderTop = this._currentMeasure.top;
  10817. this._renderWidth = this._currentMeasure.width;
  10818. this._renderHeight = this._currentMeasure.height;
  10819. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10820. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10821. this._effectiveThumbThickness = this._getThumbThickness(type);
  10822. if (this.displayThumb) {
  10823. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10824. }
  10825. //throw error when height is less than width for vertical slider
  10826. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10827. console.error("Height should be greater than width");
  10828. return;
  10829. }
  10830. if (this._barOffset.isPixel) {
  10831. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10832. }
  10833. else {
  10834. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10835. }
  10836. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10837. if (this.isVertical) {
  10838. this._renderLeft += this._effectiveBarOffset;
  10839. if (!this.isThumbClamped && this.displayThumb) {
  10840. this._renderTop += (this._effectiveThumbThickness / 2);
  10841. }
  10842. this._renderHeight = this._backgroundBoxLength;
  10843. this._renderWidth = this._backgroundBoxThickness;
  10844. }
  10845. else {
  10846. this._renderTop += this._effectiveBarOffset;
  10847. if (!this.isThumbClamped && this.displayThumb) {
  10848. this._renderLeft += (this._effectiveThumbThickness / 2);
  10849. }
  10850. this._renderHeight = this._backgroundBoxThickness;
  10851. this._renderWidth = this._backgroundBoxLength;
  10852. }
  10853. };
  10854. /** @hidden */
  10855. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10856. if (this.rotation != 0) {
  10857. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10858. x = this._transformedPosition.x;
  10859. y = this._transformedPosition.y;
  10860. }
  10861. var value;
  10862. if (this._isVertical) {
  10863. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10864. }
  10865. else {
  10866. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10867. }
  10868. var mult = (1 / this._step) | 0;
  10869. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10870. };
  10871. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10872. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10873. return false;
  10874. }
  10875. this._pointerIsDown = true;
  10876. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10877. this._host._capturingControl[pointerId] = this;
  10878. this._lastPointerDownID = pointerId;
  10879. return true;
  10880. };
  10881. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10882. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10883. if (pointerId != this._lastPointerDownID) {
  10884. return;
  10885. }
  10886. if (this._pointerIsDown) {
  10887. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10888. }
  10889. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10890. };
  10891. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10892. this._pointerIsDown = false;
  10893. delete this._host._capturingControl[pointerId];
  10894. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10895. };
  10896. return BaseSlider;
  10897. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10898. /***/ }),
  10899. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10900. /*!*************************************************!*\
  10901. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10902. \*************************************************/
  10903. /*! exports provided: ImageBasedSlider */
  10904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10905. "use strict";
  10906. __webpack_require__.r(__webpack_exports__);
  10907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10908. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10909. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10910. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10911. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  10912. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10913. /**
  10914. * Class used to create slider controls based on images
  10915. */
  10916. var ImageBasedSlider = /** @class */ (function (_super) {
  10917. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10918. /**
  10919. * Creates a new ImageBasedSlider
  10920. * @param name defines the control name
  10921. */
  10922. function ImageBasedSlider(name) {
  10923. var _this = _super.call(this, name) || this;
  10924. _this.name = name;
  10925. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10926. return _this;
  10927. }
  10928. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10929. get: function () {
  10930. return this._displayThumb && this.thumbImage != null;
  10931. },
  10932. set: function (value) {
  10933. if (this._displayThumb === value) {
  10934. return;
  10935. }
  10936. this._displayThumb = value;
  10937. this._markAsDirty();
  10938. },
  10939. enumerable: true,
  10940. configurable: true
  10941. });
  10942. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10943. /**
  10944. * Gets or sets the image used to render the background
  10945. */
  10946. get: function () {
  10947. return this._backgroundImage;
  10948. },
  10949. set: function (value) {
  10950. var _this = this;
  10951. if (this._backgroundImage === value) {
  10952. return;
  10953. }
  10954. this._backgroundImage = value;
  10955. if (value && !value.isLoaded) {
  10956. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10957. }
  10958. this._markAsDirty();
  10959. },
  10960. enumerable: true,
  10961. configurable: true
  10962. });
  10963. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10964. /**
  10965. * Gets or sets the image used to render the value bar
  10966. */
  10967. get: function () {
  10968. return this._valueBarImage;
  10969. },
  10970. set: function (value) {
  10971. var _this = this;
  10972. if (this._valueBarImage === value) {
  10973. return;
  10974. }
  10975. this._valueBarImage = value;
  10976. if (value && !value.isLoaded) {
  10977. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10978. }
  10979. this._markAsDirty();
  10980. },
  10981. enumerable: true,
  10982. configurable: true
  10983. });
  10984. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10985. /**
  10986. * Gets or sets the image used to render the thumb
  10987. */
  10988. get: function () {
  10989. return this._thumbImage;
  10990. },
  10991. set: function (value) {
  10992. var _this = this;
  10993. if (this._thumbImage === value) {
  10994. return;
  10995. }
  10996. this._thumbImage = value;
  10997. if (value && !value.isLoaded) {
  10998. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10999. }
  11000. this._markAsDirty();
  11001. },
  11002. enumerable: true,
  11003. configurable: true
  11004. });
  11005. ImageBasedSlider.prototype._getTypeName = function () {
  11006. return "ImageBasedSlider";
  11007. };
  11008. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11009. context.save();
  11010. this._applyStates(context);
  11011. this._prepareRenderingData("rectangle");
  11012. var thumbPosition = this._getThumbPosition();
  11013. var left = this._renderLeft;
  11014. var top = this._renderTop;
  11015. var width = this._renderWidth;
  11016. var height = this._renderHeight;
  11017. // Background
  11018. if (this._backgroundImage) {
  11019. this._tempMeasure.copyFromFloats(left, top, width, height);
  11020. if (this.isThumbClamped && this.displayThumb) {
  11021. if (this.isVertical) {
  11022. this._tempMeasure.height += this._effectiveThumbThickness;
  11023. }
  11024. else {
  11025. this._tempMeasure.width += this._effectiveThumbThickness;
  11026. }
  11027. }
  11028. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11029. this._backgroundImage._draw(context);
  11030. }
  11031. // Bar
  11032. if (this._valueBarImage) {
  11033. if (this.isVertical) {
  11034. if (this.isThumbClamped && this.displayThumb) {
  11035. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11036. }
  11037. else {
  11038. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11039. }
  11040. }
  11041. else {
  11042. if (this.isThumbClamped && this.displayThumb) {
  11043. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11044. }
  11045. else {
  11046. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11047. }
  11048. }
  11049. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11050. this._valueBarImage._draw(context);
  11051. }
  11052. // Thumb
  11053. if (this.displayThumb) {
  11054. if (this.isVertical) {
  11055. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11056. }
  11057. else {
  11058. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11059. }
  11060. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11061. this._thumbImage._draw(context);
  11062. }
  11063. context.restore();
  11064. };
  11065. return ImageBasedSlider;
  11066. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11067. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11068. /***/ }),
  11069. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11070. /*!***********************************************!*\
  11071. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11072. \***********************************************/
  11073. /*! exports provided: ImageScrollBar */
  11074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11075. "use strict";
  11076. __webpack_require__.r(__webpack_exports__);
  11077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11078. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11079. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11080. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11081. /**
  11082. * Class used to create slider controls
  11083. */
  11084. var ImageScrollBar = /** @class */ (function (_super) {
  11085. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11086. /**
  11087. * Creates a new ImageScrollBar
  11088. * @param name defines the control name
  11089. */
  11090. function ImageScrollBar(name) {
  11091. var _this = _super.call(this, name) || this;
  11092. _this.name = name;
  11093. _this._thumbLength = 0.5;
  11094. _this._thumbHeight = 1;
  11095. _this._barImageHeight = 1;
  11096. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11097. /** Number of 90° rotation to apply on the images when in vertical mode */
  11098. _this.num90RotationInVerticalMode = 1;
  11099. return _this;
  11100. }
  11101. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11102. /**
  11103. * Gets or sets the image used to render the background for horizontal bar
  11104. */
  11105. get: function () {
  11106. return this._backgroundBaseImage;
  11107. },
  11108. set: function (value) {
  11109. var _this = this;
  11110. if (this._backgroundBaseImage === value) {
  11111. return;
  11112. }
  11113. this._backgroundBaseImage = value;
  11114. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11115. if (!value.isLoaded) {
  11116. value.onImageLoadedObservable.addOnce(function () {
  11117. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11118. _this._backgroundImage = rotatedValue;
  11119. if (!rotatedValue.isLoaded) {
  11120. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11121. _this._markAsDirty();
  11122. });
  11123. }
  11124. _this._markAsDirty();
  11125. });
  11126. }
  11127. else {
  11128. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11129. this._markAsDirty();
  11130. }
  11131. }
  11132. else {
  11133. this._backgroundImage = value;
  11134. if (value && !value.isLoaded) {
  11135. value.onImageLoadedObservable.addOnce(function () {
  11136. _this._markAsDirty();
  11137. });
  11138. }
  11139. this._markAsDirty();
  11140. }
  11141. },
  11142. enumerable: true,
  11143. configurable: true
  11144. });
  11145. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11146. /**
  11147. * Gets or sets the image used to render the thumb
  11148. */
  11149. get: function () {
  11150. return this._thumbBaseImage;
  11151. },
  11152. set: function (value) {
  11153. var _this = this;
  11154. if (this._thumbBaseImage === value) {
  11155. return;
  11156. }
  11157. this._thumbBaseImage = value;
  11158. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11159. if (!value.isLoaded) {
  11160. value.onImageLoadedObservable.addOnce(function () {
  11161. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11162. _this._thumbImage = rotatedValue;
  11163. if (!rotatedValue.isLoaded) {
  11164. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11165. _this._markAsDirty();
  11166. });
  11167. }
  11168. _this._markAsDirty();
  11169. });
  11170. }
  11171. else {
  11172. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11173. this._markAsDirty();
  11174. }
  11175. }
  11176. else {
  11177. this._thumbImage = value;
  11178. if (value && !value.isLoaded) {
  11179. value.onImageLoadedObservable.addOnce(function () {
  11180. _this._markAsDirty();
  11181. });
  11182. }
  11183. this._markAsDirty();
  11184. }
  11185. },
  11186. enumerable: true,
  11187. configurable: true
  11188. });
  11189. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11190. /**
  11191. * Gets or sets the length of the thumb
  11192. */
  11193. get: function () {
  11194. return this._thumbLength;
  11195. },
  11196. set: function (value) {
  11197. if (this._thumbLength === value) {
  11198. return;
  11199. }
  11200. this._thumbLength = value;
  11201. this._markAsDirty();
  11202. },
  11203. enumerable: true,
  11204. configurable: true
  11205. });
  11206. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11207. /**
  11208. * Gets or sets the height of the thumb
  11209. */
  11210. get: function () {
  11211. return this._thumbHeight;
  11212. },
  11213. set: function (value) {
  11214. if (this._thumbLength === value) {
  11215. return;
  11216. }
  11217. this._thumbHeight = value;
  11218. this._markAsDirty();
  11219. },
  11220. enumerable: true,
  11221. configurable: true
  11222. });
  11223. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11224. /**
  11225. * Gets or sets the height of the bar image
  11226. */
  11227. get: function () {
  11228. return this._barImageHeight;
  11229. },
  11230. set: function (value) {
  11231. if (this._barImageHeight === value) {
  11232. return;
  11233. }
  11234. this._barImageHeight = value;
  11235. this._markAsDirty();
  11236. },
  11237. enumerable: true,
  11238. configurable: true
  11239. });
  11240. ImageScrollBar.prototype._getTypeName = function () {
  11241. return "ImageScrollBar";
  11242. };
  11243. ImageScrollBar.prototype._getThumbThickness = function () {
  11244. var thumbThickness = 0;
  11245. if (this._thumbWidth.isPixel) {
  11246. thumbThickness = this._thumbWidth.getValue(this._host);
  11247. }
  11248. else {
  11249. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11250. }
  11251. return thumbThickness;
  11252. };
  11253. ImageScrollBar.prototype._draw = function (context) {
  11254. context.save();
  11255. this._applyStates(context);
  11256. this._prepareRenderingData("rectangle");
  11257. var thumbPosition = this._getThumbPosition();
  11258. var left = this._renderLeft;
  11259. var top = this._renderTop;
  11260. var width = this._renderWidth;
  11261. var height = this._renderHeight;
  11262. // Background
  11263. if (this._backgroundImage) {
  11264. this._tempMeasure.copyFromFloats(left, top, width, height);
  11265. if (this.isVertical) {
  11266. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11267. this._tempMeasure.height += this._effectiveThumbThickness;
  11268. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11269. }
  11270. else {
  11271. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11272. this._tempMeasure.width += this._effectiveThumbThickness;
  11273. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11274. }
  11275. this._backgroundImage._draw(context);
  11276. }
  11277. // Thumb
  11278. if (this.isVertical) {
  11279. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5, this._currentMeasure.top + thumbPosition, this._currentMeasure.width * this._thumbHeight, this._effectiveThumbThickness);
  11280. }
  11281. else {
  11282. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5, this._effectiveThumbThickness, this._currentMeasure.height * this._thumbHeight);
  11283. }
  11284. if (this._thumbImage) {
  11285. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11286. this._thumbImage._draw(context);
  11287. }
  11288. context.restore();
  11289. };
  11290. /** @hidden */
  11291. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11292. if (this.rotation != 0) {
  11293. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11294. x = this._transformedPosition.x;
  11295. y = this._transformedPosition.y;
  11296. }
  11297. if (this._first) {
  11298. this._first = false;
  11299. this._originX = x;
  11300. this._originY = y;
  11301. // Check if move is required
  11302. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11303. if (this.isVertical) {
  11304. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11305. }
  11306. else {
  11307. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11308. }
  11309. }
  11310. }
  11311. // Delta mode
  11312. var delta = 0;
  11313. if (this.isVertical) {
  11314. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11315. }
  11316. else {
  11317. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11318. }
  11319. this.value += delta * (this.maximum - this.minimum);
  11320. this._originX = x;
  11321. this._originY = y;
  11322. };
  11323. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11324. this._first = true;
  11325. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11326. };
  11327. return ImageScrollBar;
  11328. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11329. /***/ }),
  11330. /***/ "./2D/controls/sliders/scrollBar.ts":
  11331. /*!******************************************!*\
  11332. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11333. \******************************************/
  11334. /*! exports provided: ScrollBar */
  11335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11336. "use strict";
  11337. __webpack_require__.r(__webpack_exports__);
  11338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11339. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11340. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11341. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11342. /**
  11343. * Class used to create slider controls
  11344. */
  11345. var ScrollBar = /** @class */ (function (_super) {
  11346. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11347. /**
  11348. * Creates a new Slider
  11349. * @param name defines the control name
  11350. */
  11351. function ScrollBar(name) {
  11352. var _this = _super.call(this, name) || this;
  11353. _this.name = name;
  11354. _this._background = "black";
  11355. _this._borderColor = "white";
  11356. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11357. return _this;
  11358. }
  11359. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11360. /** Gets or sets border color */
  11361. get: function () {
  11362. return this._borderColor;
  11363. },
  11364. set: function (value) {
  11365. if (this._borderColor === value) {
  11366. return;
  11367. }
  11368. this._borderColor = value;
  11369. this._markAsDirty();
  11370. },
  11371. enumerable: true,
  11372. configurable: true
  11373. });
  11374. Object.defineProperty(ScrollBar.prototype, "background", {
  11375. /** Gets or sets background color */
  11376. get: function () {
  11377. return this._background;
  11378. },
  11379. set: function (value) {
  11380. if (this._background === value) {
  11381. return;
  11382. }
  11383. this._background = value;
  11384. this._markAsDirty();
  11385. },
  11386. enumerable: true,
  11387. configurable: true
  11388. });
  11389. ScrollBar.prototype._getTypeName = function () {
  11390. return "Scrollbar";
  11391. };
  11392. ScrollBar.prototype._getThumbThickness = function () {
  11393. var thumbThickness = 0;
  11394. if (this._thumbWidth.isPixel) {
  11395. thumbThickness = this._thumbWidth.getValue(this._host);
  11396. }
  11397. else {
  11398. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11399. }
  11400. return thumbThickness;
  11401. };
  11402. ScrollBar.prototype._draw = function (context) {
  11403. context.save();
  11404. this._applyStates(context);
  11405. this._prepareRenderingData("rectangle");
  11406. var left = this._renderLeft;
  11407. var thumbPosition = this._getThumbPosition();
  11408. context.fillStyle = this._background;
  11409. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11410. // Value bar
  11411. context.fillStyle = this.color;
  11412. // Thumb
  11413. if (this.isVertical) {
  11414. this._tempMeasure.left = left - this._effectiveBarOffset;
  11415. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11416. this._tempMeasure.width = this._currentMeasure.width;
  11417. this._tempMeasure.height = this._effectiveThumbThickness;
  11418. }
  11419. else {
  11420. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11421. this._tempMeasure.top = this._currentMeasure.top;
  11422. this._tempMeasure.width = this._effectiveThumbThickness;
  11423. this._tempMeasure.height = this._currentMeasure.height;
  11424. }
  11425. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11426. context.restore();
  11427. };
  11428. /** @hidden */
  11429. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11430. if (this.rotation != 0) {
  11431. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11432. x = this._transformedPosition.x;
  11433. y = this._transformedPosition.y;
  11434. }
  11435. if (this._first) {
  11436. this._first = false;
  11437. this._originX = x;
  11438. this._originY = y;
  11439. // Check if move is required
  11440. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11441. if (this.isVertical) {
  11442. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11443. }
  11444. else {
  11445. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11446. }
  11447. }
  11448. }
  11449. // Delta mode
  11450. var delta = 0;
  11451. if (this.isVertical) {
  11452. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11453. }
  11454. else {
  11455. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11456. }
  11457. this.value += delta * (this.maximum - this.minimum);
  11458. this._originX = x;
  11459. this._originY = y;
  11460. };
  11461. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11462. this._first = true;
  11463. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11464. };
  11465. return ScrollBar;
  11466. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11467. /***/ }),
  11468. /***/ "./2D/controls/sliders/slider.ts":
  11469. /*!***************************************!*\
  11470. !*** ./2D/controls/sliders/slider.ts ***!
  11471. \***************************************/
  11472. /*! exports provided: Slider */
  11473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11474. "use strict";
  11475. __webpack_require__.r(__webpack_exports__);
  11476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11478. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11479. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  11480. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11481. /**
  11482. * Class used to create slider controls
  11483. */
  11484. var Slider = /** @class */ (function (_super) {
  11485. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11486. /**
  11487. * Creates a new Slider
  11488. * @param name defines the control name
  11489. */
  11490. function Slider(name) {
  11491. var _this = _super.call(this, name) || this;
  11492. _this.name = name;
  11493. _this._background = "black";
  11494. _this._borderColor = "white";
  11495. _this._isThumbCircle = false;
  11496. _this._displayValueBar = true;
  11497. return _this;
  11498. }
  11499. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11500. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11501. get: function () {
  11502. return this._displayValueBar;
  11503. },
  11504. set: function (value) {
  11505. if (this._displayValueBar === value) {
  11506. return;
  11507. }
  11508. this._displayValueBar = value;
  11509. this._markAsDirty();
  11510. },
  11511. enumerable: true,
  11512. configurable: true
  11513. });
  11514. Object.defineProperty(Slider.prototype, "borderColor", {
  11515. /** Gets or sets border color */
  11516. get: function () {
  11517. return this._borderColor;
  11518. },
  11519. set: function (value) {
  11520. if (this._borderColor === value) {
  11521. return;
  11522. }
  11523. this._borderColor = value;
  11524. this._markAsDirty();
  11525. },
  11526. enumerable: true,
  11527. configurable: true
  11528. });
  11529. Object.defineProperty(Slider.prototype, "background", {
  11530. /** Gets or sets background color */
  11531. get: function () {
  11532. return this._background;
  11533. },
  11534. set: function (value) {
  11535. if (this._background === value) {
  11536. return;
  11537. }
  11538. this._background = value;
  11539. this._markAsDirty();
  11540. },
  11541. enumerable: true,
  11542. configurable: true
  11543. });
  11544. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11545. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11546. get: function () {
  11547. return this._isThumbCircle;
  11548. },
  11549. set: function (value) {
  11550. if (this._isThumbCircle === value) {
  11551. return;
  11552. }
  11553. this._isThumbCircle = value;
  11554. this._markAsDirty();
  11555. },
  11556. enumerable: true,
  11557. configurable: true
  11558. });
  11559. Slider.prototype._getTypeName = function () {
  11560. return "Slider";
  11561. };
  11562. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11563. context.save();
  11564. this._applyStates(context);
  11565. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11566. var left = this._renderLeft;
  11567. var top = this._renderTop;
  11568. var width = this._renderWidth;
  11569. var height = this._renderHeight;
  11570. var radius = 0;
  11571. if (this.isThumbClamped && this.isThumbCircle) {
  11572. if (this.isVertical) {
  11573. top += (this._effectiveThumbThickness / 2);
  11574. }
  11575. else {
  11576. left += (this._effectiveThumbThickness / 2);
  11577. }
  11578. radius = this._backgroundBoxThickness / 2;
  11579. }
  11580. else {
  11581. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11582. }
  11583. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11584. context.shadowColor = this.shadowColor;
  11585. context.shadowBlur = this.shadowBlur;
  11586. context.shadowOffsetX = this.shadowOffsetX;
  11587. context.shadowOffsetY = this.shadowOffsetY;
  11588. }
  11589. var thumbPosition = this._getThumbPosition();
  11590. context.fillStyle = this._background;
  11591. if (this.isVertical) {
  11592. if (this.isThumbClamped) {
  11593. if (this.isThumbCircle) {
  11594. context.beginPath();
  11595. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11596. context.fill();
  11597. context.fillRect(left, top, width, height);
  11598. }
  11599. else {
  11600. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11601. }
  11602. }
  11603. else {
  11604. context.fillRect(left, top, width, height);
  11605. }
  11606. }
  11607. else {
  11608. if (this.isThumbClamped) {
  11609. if (this.isThumbCircle) {
  11610. context.beginPath();
  11611. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11612. context.fill();
  11613. context.fillRect(left, top, width, height);
  11614. }
  11615. else {
  11616. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11617. }
  11618. }
  11619. else {
  11620. context.fillRect(left, top, width, height);
  11621. }
  11622. }
  11623. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11624. context.shadowBlur = 0;
  11625. context.shadowOffsetX = 0;
  11626. context.shadowOffsetY = 0;
  11627. }
  11628. // Value bar
  11629. context.fillStyle = this.color;
  11630. if (this._displayValueBar) {
  11631. if (this.isVertical) {
  11632. if (this.isThumbClamped) {
  11633. if (this.isThumbCircle) {
  11634. context.beginPath();
  11635. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11636. context.fill();
  11637. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11638. }
  11639. else {
  11640. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11641. }
  11642. }
  11643. else {
  11644. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11645. }
  11646. }
  11647. else {
  11648. if (this.isThumbClamped) {
  11649. if (this.isThumbCircle) {
  11650. context.beginPath();
  11651. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11652. context.fill();
  11653. context.fillRect(left, top, thumbPosition, height);
  11654. }
  11655. else {
  11656. context.fillRect(left, top, thumbPosition, height);
  11657. }
  11658. }
  11659. else {
  11660. context.fillRect(left, top, thumbPosition, height);
  11661. }
  11662. }
  11663. }
  11664. // Thumb
  11665. if (this.displayThumb) {
  11666. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11667. context.shadowColor = this.shadowColor;
  11668. context.shadowBlur = this.shadowBlur;
  11669. context.shadowOffsetX = this.shadowOffsetX;
  11670. context.shadowOffsetY = this.shadowOffsetY;
  11671. }
  11672. if (this._isThumbCircle) {
  11673. context.beginPath();
  11674. if (this.isVertical) {
  11675. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11676. }
  11677. else {
  11678. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11679. }
  11680. context.fill();
  11681. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11682. context.shadowBlur = 0;
  11683. context.shadowOffsetX = 0;
  11684. context.shadowOffsetY = 0;
  11685. }
  11686. context.strokeStyle = this._borderColor;
  11687. context.stroke();
  11688. }
  11689. else {
  11690. if (this.isVertical) {
  11691. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11692. }
  11693. else {
  11694. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11695. }
  11696. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11697. context.shadowBlur = 0;
  11698. context.shadowOffsetX = 0;
  11699. context.shadowOffsetY = 0;
  11700. }
  11701. context.strokeStyle = this._borderColor;
  11702. if (this.isVertical) {
  11703. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11704. }
  11705. else {
  11706. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11707. }
  11708. }
  11709. }
  11710. context.restore();
  11711. };
  11712. return Slider;
  11713. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11714. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11715. /***/ }),
  11716. /***/ "./2D/controls/stackPanel.ts":
  11717. /*!***********************************!*\
  11718. !*** ./2D/controls/stackPanel.ts ***!
  11719. \***********************************/
  11720. /*! exports provided: StackPanel */
  11721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11722. "use strict";
  11723. __webpack_require__.r(__webpack_exports__);
  11724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11726. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  11727. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11728. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11729. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11730. /**
  11731. * Class used to create a 2D stack panel container
  11732. */
  11733. var StackPanel = /** @class */ (function (_super) {
  11734. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11735. /**
  11736. * Creates a new StackPanel
  11737. * @param name defines control name
  11738. */
  11739. function StackPanel(name) {
  11740. var _this = _super.call(this, name) || this;
  11741. _this.name = name;
  11742. _this._isVertical = true;
  11743. _this._manualWidth = false;
  11744. _this._manualHeight = false;
  11745. _this._doNotTrackManualChanges = false;
  11746. /**
  11747. * Gets or sets a boolean indicating that layou warnings should be ignored
  11748. */
  11749. _this.ignoreLayoutWarnings = false;
  11750. return _this;
  11751. }
  11752. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11753. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11754. get: function () {
  11755. return this._isVertical;
  11756. },
  11757. set: function (value) {
  11758. if (this._isVertical === value) {
  11759. return;
  11760. }
  11761. this._isVertical = value;
  11762. this._markAsDirty();
  11763. },
  11764. enumerable: true,
  11765. configurable: true
  11766. });
  11767. Object.defineProperty(StackPanel.prototype, "width", {
  11768. get: function () {
  11769. return this._width.toString(this._host);
  11770. },
  11771. /**
  11772. * Gets or sets panel width.
  11773. * This value should not be set when in horizontal mode as it will be computed automatically
  11774. */
  11775. set: function (value) {
  11776. if (!this._doNotTrackManualChanges) {
  11777. this._manualWidth = true;
  11778. }
  11779. if (this._width.toString(this._host) === value) {
  11780. return;
  11781. }
  11782. if (this._width.fromString(value)) {
  11783. this._markAsDirty();
  11784. }
  11785. },
  11786. enumerable: true,
  11787. configurable: true
  11788. });
  11789. Object.defineProperty(StackPanel.prototype, "height", {
  11790. get: function () {
  11791. return this._height.toString(this._host);
  11792. },
  11793. /**
  11794. * Gets or sets panel height.
  11795. * This value should not be set when in vertical mode as it will be computed automatically
  11796. */
  11797. set: function (value) {
  11798. if (!this._doNotTrackManualChanges) {
  11799. this._manualHeight = true;
  11800. }
  11801. if (this._height.toString(this._host) === value) {
  11802. return;
  11803. }
  11804. if (this._height.fromString(value)) {
  11805. this._markAsDirty();
  11806. }
  11807. },
  11808. enumerable: true,
  11809. configurable: true
  11810. });
  11811. StackPanel.prototype._getTypeName = function () {
  11812. return "StackPanel";
  11813. };
  11814. /** @hidden */
  11815. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11816. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11817. var child = _a[_i];
  11818. if (this._isVertical) {
  11819. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11820. }
  11821. else {
  11822. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11823. }
  11824. }
  11825. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11826. };
  11827. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11828. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11829. this._measureForChildren.copyFrom(parentMeasure);
  11830. this._measureForChildren.left = this._currentMeasure.left;
  11831. this._measureForChildren.top = this._currentMeasure.top;
  11832. if (!this.isVertical || this._manualWidth) {
  11833. this._measureForChildren.width = this._currentMeasure.width;
  11834. }
  11835. if (this.isVertical || this._manualHeight) {
  11836. this._measureForChildren.height = this._currentMeasure.height;
  11837. }
  11838. };
  11839. StackPanel.prototype._postMeasure = function () {
  11840. var stackWidth = 0;
  11841. var stackHeight = 0;
  11842. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11843. var child = _a[_i];
  11844. if (!child.isVisible || child.notRenderable) {
  11845. continue;
  11846. }
  11847. if (this._isVertical) {
  11848. if (child.top !== stackHeight + "px") {
  11849. child.top = stackHeight + "px";
  11850. this._rebuildLayout = true;
  11851. child._top.ignoreAdaptiveScaling = true;
  11852. }
  11853. if (child._height.isPercentage && !child._automaticSize) {
  11854. if (!this.ignoreLayoutWarnings) {
  11855. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using height in percentage mode inside a vertical StackPanel");
  11856. }
  11857. }
  11858. else {
  11859. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11860. }
  11861. }
  11862. else {
  11863. if (child.left !== stackWidth + "px") {
  11864. child.left = stackWidth + "px";
  11865. this._rebuildLayout = true;
  11866. child._left.ignoreAdaptiveScaling = true;
  11867. }
  11868. if (child._width.isPercentage && !child._automaticSize) {
  11869. if (!this.ignoreLayoutWarnings) {
  11870. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using width in percentage mode inside a horizontal StackPanel");
  11871. }
  11872. }
  11873. else {
  11874. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11875. }
  11876. }
  11877. }
  11878. this._doNotTrackManualChanges = true;
  11879. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11880. // User can now define their own height and width for stack panel.
  11881. var panelWidthChanged = false;
  11882. var panelHeightChanged = false;
  11883. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11884. var previousHeight = this.height;
  11885. this.height = stackHeight + "px";
  11886. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11887. }
  11888. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11889. var previousWidth = this.width;
  11890. this.width = stackWidth + "px";
  11891. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11892. }
  11893. if (panelHeightChanged) {
  11894. this._height.ignoreAdaptiveScaling = true;
  11895. }
  11896. if (panelWidthChanged) {
  11897. this._width.ignoreAdaptiveScaling = true;
  11898. }
  11899. this._doNotTrackManualChanges = false;
  11900. if (panelWidthChanged || panelHeightChanged) {
  11901. this._rebuildLayout = true;
  11902. }
  11903. _super.prototype._postMeasure.call(this);
  11904. };
  11905. return StackPanel;
  11906. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11907. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11908. /***/ }),
  11909. /***/ "./2D/controls/statics.ts":
  11910. /*!********************************!*\
  11911. !*** ./2D/controls/statics.ts ***!
  11912. \********************************/
  11913. /*! exports provided: name */
  11914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11915. "use strict";
  11916. __webpack_require__.r(__webpack_exports__);
  11917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11918. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11919. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11920. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11921. /**
  11922. * Forcing an export so that this code will execute
  11923. * @hidden
  11924. */
  11925. var name = "Statics";
  11926. /**
  11927. * Creates a stack panel that can be used to render headers
  11928. * @param control defines the control to associate with the header
  11929. * @param text defines the text of the header
  11930. * @param size defines the size of the header
  11931. * @param options defines options used to configure the header
  11932. * @returns a new StackPanel
  11933. */
  11934. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11935. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11936. var isHorizontal = options ? options.isHorizontal : true;
  11937. var controlFirst = options ? options.controlFirst : true;
  11938. panel.isVertical = !isHorizontal;
  11939. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11940. header.text = text;
  11941. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11942. if (isHorizontal) {
  11943. header.width = size;
  11944. }
  11945. else {
  11946. header.height = size;
  11947. }
  11948. if (controlFirst) {
  11949. panel.addControl(control);
  11950. panel.addControl(header);
  11951. header.paddingLeft = "5px";
  11952. }
  11953. else {
  11954. panel.addControl(header);
  11955. panel.addControl(control);
  11956. header.paddingRight = "5px";
  11957. }
  11958. header.shadowBlur = control.shadowBlur;
  11959. header.shadowColor = control.shadowColor;
  11960. header.shadowOffsetX = control.shadowOffsetX;
  11961. header.shadowOffsetY = control.shadowOffsetY;
  11962. return panel;
  11963. };
  11964. /***/ }),
  11965. /***/ "./2D/controls/textBlock.ts":
  11966. /*!**********************************!*\
  11967. !*** ./2D/controls/textBlock.ts ***!
  11968. \**********************************/
  11969. /*! exports provided: TextWrapping, TextBlock */
  11970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11971. "use strict";
  11972. __webpack_require__.r(__webpack_exports__);
  11973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11975. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11976. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  11977. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11978. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11979. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11980. /**
  11981. * Enum that determines the text-wrapping mode to use.
  11982. */
  11983. var TextWrapping;
  11984. (function (TextWrapping) {
  11985. /**
  11986. * Clip the text when it's larger than Control.width; this is the default mode.
  11987. */
  11988. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11989. /**
  11990. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11991. */
  11992. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11993. /**
  11994. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11995. */
  11996. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11997. })(TextWrapping || (TextWrapping = {}));
  11998. /**
  11999. * Class used to create text block control
  12000. */
  12001. var TextBlock = /** @class */ (function (_super) {
  12002. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12003. /**
  12004. * Creates a new TextBlock object
  12005. * @param name defines the name of the control
  12006. * @param text defines the text to display (emptry string by default)
  12007. */
  12008. function TextBlock(
  12009. /**
  12010. * Defines the name of the control
  12011. */
  12012. name, text) {
  12013. if (text === void 0) { text = ""; }
  12014. var _this = _super.call(this, name) || this;
  12015. _this.name = name;
  12016. _this._text = "";
  12017. _this._textWrapping = TextWrapping.Clip;
  12018. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12019. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12020. _this._resizeToFit = false;
  12021. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12022. _this._outlineWidth = 0;
  12023. _this._outlineColor = "white";
  12024. /**
  12025. * An event triggered after the text is changed
  12026. */
  12027. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12028. /**
  12029. * An event triggered after the text was broken up into lines
  12030. */
  12031. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12032. _this.text = text;
  12033. return _this;
  12034. }
  12035. Object.defineProperty(TextBlock.prototype, "lines", {
  12036. /**
  12037. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12038. */
  12039. get: function () {
  12040. return this._lines;
  12041. },
  12042. enumerable: true,
  12043. configurable: true
  12044. });
  12045. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12046. /**
  12047. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12048. */
  12049. get: function () {
  12050. return this._resizeToFit;
  12051. },
  12052. /**
  12053. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12054. */
  12055. set: function (value) {
  12056. if (this._resizeToFit === value) {
  12057. return;
  12058. }
  12059. this._resizeToFit = value;
  12060. if (this._resizeToFit) {
  12061. this._width.ignoreAdaptiveScaling = true;
  12062. this._height.ignoreAdaptiveScaling = true;
  12063. }
  12064. this._markAsDirty();
  12065. },
  12066. enumerable: true,
  12067. configurable: true
  12068. });
  12069. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12070. /**
  12071. * Gets or sets a boolean indicating if text must be wrapped
  12072. */
  12073. get: function () {
  12074. return this._textWrapping;
  12075. },
  12076. /**
  12077. * Gets or sets a boolean indicating if text must be wrapped
  12078. */
  12079. set: function (value) {
  12080. if (this._textWrapping === value) {
  12081. return;
  12082. }
  12083. this._textWrapping = +value;
  12084. this._markAsDirty();
  12085. },
  12086. enumerable: true,
  12087. configurable: true
  12088. });
  12089. Object.defineProperty(TextBlock.prototype, "text", {
  12090. /**
  12091. * Gets or sets text to display
  12092. */
  12093. get: function () {
  12094. return this._text;
  12095. },
  12096. /**
  12097. * Gets or sets text to display
  12098. */
  12099. set: function (value) {
  12100. if (this._text === value) {
  12101. return;
  12102. }
  12103. this._text = value;
  12104. this._markAsDirty();
  12105. this.onTextChangedObservable.notifyObservers(this);
  12106. },
  12107. enumerable: true,
  12108. configurable: true
  12109. });
  12110. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12111. /**
  12112. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12113. */
  12114. get: function () {
  12115. return this._textHorizontalAlignment;
  12116. },
  12117. /**
  12118. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12119. */
  12120. set: function (value) {
  12121. if (this._textHorizontalAlignment === value) {
  12122. return;
  12123. }
  12124. this._textHorizontalAlignment = value;
  12125. this._markAsDirty();
  12126. },
  12127. enumerable: true,
  12128. configurable: true
  12129. });
  12130. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12131. /**
  12132. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12133. */
  12134. get: function () {
  12135. return this._textVerticalAlignment;
  12136. },
  12137. /**
  12138. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12139. */
  12140. set: function (value) {
  12141. if (this._textVerticalAlignment === value) {
  12142. return;
  12143. }
  12144. this._textVerticalAlignment = value;
  12145. this._markAsDirty();
  12146. },
  12147. enumerable: true,
  12148. configurable: true
  12149. });
  12150. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12151. /**
  12152. * Gets or sets line spacing value
  12153. */
  12154. get: function () {
  12155. return this._lineSpacing.toString(this._host);
  12156. },
  12157. /**
  12158. * Gets or sets line spacing value
  12159. */
  12160. set: function (value) {
  12161. if (this._lineSpacing.fromString(value)) {
  12162. this._markAsDirty();
  12163. }
  12164. },
  12165. enumerable: true,
  12166. configurable: true
  12167. });
  12168. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12169. /**
  12170. * Gets or sets outlineWidth of the text to display
  12171. */
  12172. get: function () {
  12173. return this._outlineWidth;
  12174. },
  12175. /**
  12176. * Gets or sets outlineWidth of the text to display
  12177. */
  12178. set: function (value) {
  12179. if (this._outlineWidth === value) {
  12180. return;
  12181. }
  12182. this._outlineWidth = value;
  12183. this._markAsDirty();
  12184. },
  12185. enumerable: true,
  12186. configurable: true
  12187. });
  12188. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12189. /**
  12190. * Gets or sets outlineColor of the text to display
  12191. */
  12192. get: function () {
  12193. return this._outlineColor;
  12194. },
  12195. /**
  12196. * Gets or sets outlineColor of the text to display
  12197. */
  12198. set: function (value) {
  12199. if (this._outlineColor === value) {
  12200. return;
  12201. }
  12202. this._outlineColor = value;
  12203. this._markAsDirty();
  12204. },
  12205. enumerable: true,
  12206. configurable: true
  12207. });
  12208. TextBlock.prototype._getTypeName = function () {
  12209. return "TextBlock";
  12210. };
  12211. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12212. if (!this._fontOffset) {
  12213. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12214. }
  12215. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12216. // Prepare lines
  12217. this._lines = this._breakLines(this._currentMeasure.width, context);
  12218. this.onLinesReadyObservable.notifyObservers(this);
  12219. var maxLineWidth = 0;
  12220. for (var i = 0; i < this._lines.length; i++) {
  12221. var line = this._lines[i];
  12222. if (line.width > maxLineWidth) {
  12223. maxLineWidth = line.width;
  12224. }
  12225. }
  12226. if (this._resizeToFit) {
  12227. if (this._textWrapping === TextWrapping.Clip) {
  12228. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12229. if (newWidth !== this._width.internalValue) {
  12230. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12231. this._rebuildLayout = true;
  12232. }
  12233. }
  12234. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12235. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12236. var lineSpacing = 0;
  12237. if (this._lineSpacing.isPixel) {
  12238. lineSpacing = this._lineSpacing.getValue(this._host);
  12239. }
  12240. else {
  12241. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12242. }
  12243. newHeight += (this._lines.length - 1) * lineSpacing;
  12244. }
  12245. if (newHeight !== this._height.internalValue) {
  12246. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12247. this._rebuildLayout = true;
  12248. }
  12249. }
  12250. };
  12251. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12252. var width = this._currentMeasure.width;
  12253. var x = 0;
  12254. switch (this._textHorizontalAlignment) {
  12255. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12256. x = 0;
  12257. break;
  12258. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12259. x = width - textWidth;
  12260. break;
  12261. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12262. x = (width - textWidth) / 2;
  12263. break;
  12264. }
  12265. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12266. context.shadowColor = this.shadowColor;
  12267. context.shadowBlur = this.shadowBlur;
  12268. context.shadowOffsetX = this.shadowOffsetX;
  12269. context.shadowOffsetY = this.shadowOffsetY;
  12270. }
  12271. if (this.outlineWidth) {
  12272. context.strokeText(text, this._currentMeasure.left + x, y);
  12273. }
  12274. context.fillText(text, this._currentMeasure.left + x, y);
  12275. };
  12276. /** @hidden */
  12277. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12278. context.save();
  12279. this._applyStates(context);
  12280. // Render lines
  12281. this._renderLines(context);
  12282. context.restore();
  12283. };
  12284. TextBlock.prototype._applyStates = function (context) {
  12285. _super.prototype._applyStates.call(this, context);
  12286. if (this.outlineWidth) {
  12287. context.lineWidth = this.outlineWidth;
  12288. context.strokeStyle = this.outlineColor;
  12289. }
  12290. };
  12291. TextBlock.prototype._breakLines = function (refWidth, context) {
  12292. var lines = [];
  12293. var _lines = this.text.split("\n");
  12294. if (this._textWrapping === TextWrapping.Ellipsis) {
  12295. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12296. var _line = _lines_1[_i];
  12297. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12298. }
  12299. }
  12300. else if (this._textWrapping === TextWrapping.WordWrap) {
  12301. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12302. var _line = _lines_2[_a];
  12303. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12304. }
  12305. }
  12306. else {
  12307. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12308. var _line = _lines_3[_b];
  12309. lines.push(this._parseLine(_line, context));
  12310. }
  12311. }
  12312. return lines;
  12313. };
  12314. TextBlock.prototype._parseLine = function (line, context) {
  12315. if (line === void 0) { line = ''; }
  12316. return { text: line, width: context.measureText(line).width };
  12317. };
  12318. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12319. if (line === void 0) { line = ''; }
  12320. var lineWidth = context.measureText(line).width;
  12321. if (lineWidth > width) {
  12322. line += '…';
  12323. }
  12324. while (line.length > 2 && lineWidth > width) {
  12325. line = line.slice(0, -2) + '…';
  12326. lineWidth = context.measureText(line).width;
  12327. }
  12328. return { text: line, width: lineWidth };
  12329. };
  12330. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12331. if (line === void 0) { line = ''; }
  12332. var lines = [];
  12333. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(' ');
  12334. var lineWidth = 0;
  12335. for (var n = 0; n < words.length; n++) {
  12336. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12337. var metrics = context.measureText(testLine);
  12338. var testWidth = metrics.width;
  12339. if (testWidth > width && n > 0) {
  12340. lines.push({ text: line, width: lineWidth });
  12341. line = words[n];
  12342. lineWidth = context.measureText(line).width;
  12343. }
  12344. else {
  12345. lineWidth = testWidth;
  12346. line = testLine;
  12347. }
  12348. }
  12349. lines.push({ text: line, width: lineWidth });
  12350. return lines;
  12351. };
  12352. TextBlock.prototype._renderLines = function (context) {
  12353. var height = this._currentMeasure.height;
  12354. var rootY = 0;
  12355. switch (this._textVerticalAlignment) {
  12356. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12357. rootY = this._fontOffset.ascent;
  12358. break;
  12359. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12360. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12361. break;
  12362. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12363. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12364. break;
  12365. }
  12366. rootY += this._currentMeasure.top;
  12367. for (var i = 0; i < this._lines.length; i++) {
  12368. var line = this._lines[i];
  12369. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12370. if (this._lineSpacing.isPixel) {
  12371. rootY += this._lineSpacing.getValue(this._host);
  12372. }
  12373. else {
  12374. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12375. }
  12376. }
  12377. this._drawText(line.text, line.width, rootY, context);
  12378. rootY += this._fontOffset.height;
  12379. }
  12380. };
  12381. /**
  12382. * Given a width constraint applied on the text block, find the expected height
  12383. * @returns expected height
  12384. */
  12385. TextBlock.prototype.computeExpectedHeight = function () {
  12386. if (this.text && this.widthInPixels) {
  12387. var context_1 = document.createElement('canvas').getContext('2d');
  12388. if (context_1) {
  12389. this._applyStates(context_1);
  12390. if (!this._fontOffset) {
  12391. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12392. }
  12393. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12394. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12395. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12396. var lineSpacing = 0;
  12397. if (this._lineSpacing.isPixel) {
  12398. lineSpacing = this._lineSpacing.getValue(this._host);
  12399. }
  12400. else {
  12401. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12402. }
  12403. newHeight += (lines.length - 1) * lineSpacing;
  12404. }
  12405. return newHeight;
  12406. }
  12407. }
  12408. return 0;
  12409. };
  12410. TextBlock.prototype.dispose = function () {
  12411. _super.prototype.dispose.call(this);
  12412. this.onTextChangedObservable.clear();
  12413. };
  12414. return TextBlock;
  12415. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12416. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12417. /***/ }),
  12418. /***/ "./2D/controls/virtualKeyboard.ts":
  12419. /*!****************************************!*\
  12420. !*** ./2D/controls/virtualKeyboard.ts ***!
  12421. \****************************************/
  12422. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12424. "use strict";
  12425. __webpack_require__.r(__webpack_exports__);
  12426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12428. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12429. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  12430. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12431. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12432. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12433. /**
  12434. * Class used to store key control properties
  12435. */
  12436. var KeyPropertySet = /** @class */ (function () {
  12437. function KeyPropertySet() {
  12438. }
  12439. return KeyPropertySet;
  12440. }());
  12441. /**
  12442. * Class used to create virtual keyboard
  12443. */
  12444. var VirtualKeyboard = /** @class */ (function (_super) {
  12445. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12446. function VirtualKeyboard() {
  12447. var _this = _super !== null && _super.apply(this, arguments) || this;
  12448. /** Observable raised when a key is pressed */
  12449. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12450. /** Gets or sets default key button width */
  12451. _this.defaultButtonWidth = "40px";
  12452. /** Gets or sets default key button height */
  12453. _this.defaultButtonHeight = "40px";
  12454. /** Gets or sets default key button left padding */
  12455. _this.defaultButtonPaddingLeft = "2px";
  12456. /** Gets or sets default key button right padding */
  12457. _this.defaultButtonPaddingRight = "2px";
  12458. /** Gets or sets default key button top padding */
  12459. _this.defaultButtonPaddingTop = "2px";
  12460. /** Gets or sets default key button bottom padding */
  12461. _this.defaultButtonPaddingBottom = "2px";
  12462. /** Gets or sets default key button foreground color */
  12463. _this.defaultButtonColor = "#DDD";
  12464. /** Gets or sets default key button background color */
  12465. _this.defaultButtonBackground = "#070707";
  12466. /** Gets or sets shift button foreground color */
  12467. _this.shiftButtonColor = "#7799FF";
  12468. /** Gets or sets shift button thickness*/
  12469. _this.selectedShiftThickness = 1;
  12470. /** Gets shift key state */
  12471. _this.shiftState = 0;
  12472. _this._currentlyConnectedInputText = null;
  12473. _this._connectedInputTexts = [];
  12474. _this._onKeyPressObserver = null;
  12475. return _this;
  12476. }
  12477. VirtualKeyboard.prototype._getTypeName = function () {
  12478. return "VirtualKeyboard";
  12479. };
  12480. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12481. var _this = this;
  12482. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12483. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12484. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12485. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12486. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12487. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12488. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12489. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12490. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12491. button.thickness = 0;
  12492. button.isFocusInvisible = true;
  12493. button.shadowColor = this.shadowColor;
  12494. button.shadowBlur = this.shadowBlur;
  12495. button.shadowOffsetX = this.shadowOffsetX;
  12496. button.shadowOffsetY = this.shadowOffsetY;
  12497. button.onPointerUpObservable.add(function () {
  12498. _this.onKeyPressObservable.notifyObservers(key);
  12499. });
  12500. return button;
  12501. };
  12502. /**
  12503. * Adds a new row of keys
  12504. * @param keys defines the list of keys to add
  12505. * @param propertySets defines the associated property sets
  12506. */
  12507. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12508. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12509. panel.isVertical = false;
  12510. panel.isFocusInvisible = true;
  12511. var maxKey = null;
  12512. for (var i = 0; i < keys.length; i++) {
  12513. var properties = null;
  12514. if (propertySets && propertySets.length === keys.length) {
  12515. properties = propertySets[i];
  12516. }
  12517. var key = this._createKey(keys[i], properties);
  12518. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12519. maxKey = key;
  12520. }
  12521. panel.addControl(key);
  12522. }
  12523. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12524. this.addControl(panel);
  12525. };
  12526. /**
  12527. * Set the shift key to a specific state
  12528. * @param shiftState defines the new shift state
  12529. */
  12530. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12531. if (!this.children) {
  12532. return;
  12533. }
  12534. for (var i = 0; i < this.children.length; i++) {
  12535. var row = this.children[i];
  12536. if (!row || !row.children) {
  12537. continue;
  12538. }
  12539. var rowContainer = row;
  12540. for (var j = 0; j < rowContainer.children.length; j++) {
  12541. var button = rowContainer.children[j];
  12542. if (!button || !button.children[0]) {
  12543. continue;
  12544. }
  12545. var button_tblock = button.children[0];
  12546. if (button_tblock.text === "\u21E7") {
  12547. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12548. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12549. }
  12550. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12551. }
  12552. }
  12553. };
  12554. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12555. /** Gets the input text control currently attached to the keyboard */
  12556. get: function () {
  12557. return this._currentlyConnectedInputText;
  12558. },
  12559. enumerable: true,
  12560. configurable: true
  12561. });
  12562. /**
  12563. * Connects the keyboard with an input text control
  12564. *
  12565. * @param input defines the target control
  12566. */
  12567. VirtualKeyboard.prototype.connect = function (input) {
  12568. var _this = this;
  12569. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12570. if (inputTextAlreadyConnected) {
  12571. return;
  12572. }
  12573. if (this._onKeyPressObserver === null) {
  12574. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12575. if (!_this._currentlyConnectedInputText) {
  12576. return;
  12577. }
  12578. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12579. switch (key) {
  12580. case "\u21E7":
  12581. _this.shiftState++;
  12582. if (_this.shiftState > 2) {
  12583. _this.shiftState = 0;
  12584. }
  12585. _this.applyShiftState(_this.shiftState);
  12586. return;
  12587. case "\u2190":
  12588. _this._currentlyConnectedInputText.processKey(8);
  12589. return;
  12590. case "\u21B5":
  12591. _this._currentlyConnectedInputText.processKey(13);
  12592. return;
  12593. }
  12594. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12595. if (_this.shiftState === 1) {
  12596. _this.shiftState = 0;
  12597. _this.applyShiftState(_this.shiftState);
  12598. }
  12599. });
  12600. }
  12601. this.isVisible = false;
  12602. this._currentlyConnectedInputText = input;
  12603. input._connectedVirtualKeyboard = this;
  12604. // Events hooking
  12605. var onFocusObserver = input.onFocusObservable.add(function () {
  12606. _this._currentlyConnectedInputText = input;
  12607. input._connectedVirtualKeyboard = _this;
  12608. _this.isVisible = true;
  12609. });
  12610. var onBlurObserver = input.onBlurObservable.add(function () {
  12611. input._connectedVirtualKeyboard = null;
  12612. _this._currentlyConnectedInputText = null;
  12613. _this.isVisible = false;
  12614. });
  12615. this._connectedInputTexts.push({
  12616. input: input,
  12617. onBlurObserver: onBlurObserver,
  12618. onFocusObserver: onFocusObserver
  12619. });
  12620. };
  12621. /**
  12622. * Disconnects the keyboard from connected InputText controls
  12623. *
  12624. * @param input optionally defines a target control, otherwise all are disconnected
  12625. */
  12626. VirtualKeyboard.prototype.disconnect = function (input) {
  12627. var _this = this;
  12628. if (input) {
  12629. // .find not available on IE
  12630. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12631. if (filtered.length === 1) {
  12632. this._removeConnectedInputObservables(filtered[0]);
  12633. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12634. if (this._currentlyConnectedInputText === input) {
  12635. this._currentlyConnectedInputText = null;
  12636. }
  12637. }
  12638. }
  12639. else {
  12640. this._connectedInputTexts.forEach(function (connectedInputText) {
  12641. _this._removeConnectedInputObservables(connectedInputText);
  12642. });
  12643. this._connectedInputTexts = [];
  12644. }
  12645. if (this._connectedInputTexts.length === 0) {
  12646. this._currentlyConnectedInputText = null;
  12647. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12648. this._onKeyPressObserver = null;
  12649. }
  12650. };
  12651. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12652. connectedInputText.input._connectedVirtualKeyboard = null;
  12653. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12654. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12655. };
  12656. /**
  12657. * Release all resources
  12658. */
  12659. VirtualKeyboard.prototype.dispose = function () {
  12660. _super.prototype.dispose.call(this);
  12661. this.disconnect();
  12662. };
  12663. // Statics
  12664. /**
  12665. * Creates a new keyboard using a default layout
  12666. *
  12667. * @param name defines control name
  12668. * @returns a new VirtualKeyboard
  12669. */
  12670. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12671. var returnValue = new VirtualKeyboard(name);
  12672. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12673. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12674. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12675. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12676. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12677. return returnValue;
  12678. };
  12679. return VirtualKeyboard;
  12680. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12681. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12682. /***/ }),
  12683. /***/ "./2D/index.ts":
  12684. /*!*********************!*\
  12685. !*** ./2D/index.ts ***!
  12686. \*********************/
  12687. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  12688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12689. "use strict";
  12690. __webpack_require__.r(__webpack_exports__);
  12691. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12724. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12726. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12728. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12731. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12733. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12735. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12737. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12739. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12741. /***/ }),
  12742. /***/ "./2D/math2D.ts":
  12743. /*!**********************!*\
  12744. !*** ./2D/math2D.ts ***!
  12745. \**********************/
  12746. /*! exports provided: Vector2WithInfo, Matrix2D */
  12747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12748. "use strict";
  12749. __webpack_require__.r(__webpack_exports__);
  12750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12752. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12753. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  12754. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12755. /**
  12756. * Class used to transport Vector2 information for pointer events
  12757. */
  12758. var Vector2WithInfo = /** @class */ (function (_super) {
  12759. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12760. /**
  12761. * Creates a new Vector2WithInfo
  12762. * @param source defines the vector2 data to transport
  12763. * @param buttonIndex defines the current mouse button index
  12764. */
  12765. function Vector2WithInfo(source,
  12766. /** defines the current mouse button index */
  12767. buttonIndex) {
  12768. if (buttonIndex === void 0) { buttonIndex = 0; }
  12769. var _this = _super.call(this, source.x, source.y) || this;
  12770. _this.buttonIndex = buttonIndex;
  12771. return _this;
  12772. }
  12773. return Vector2WithInfo;
  12774. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12775. /** Class used to provide 2D matrix features */
  12776. var Matrix2D = /** @class */ (function () {
  12777. /**
  12778. * Creates a new matrix
  12779. * @param m00 defines value for (0, 0)
  12780. * @param m01 defines value for (0, 1)
  12781. * @param m10 defines value for (1, 0)
  12782. * @param m11 defines value for (1, 1)
  12783. * @param m20 defines value for (2, 0)
  12784. * @param m21 defines value for (2, 1)
  12785. */
  12786. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12787. /** Gets the internal array of 6 floats used to store matrix data */
  12788. this.m = new Float32Array(6);
  12789. this.fromValues(m00, m01, m10, m11, m20, m21);
  12790. }
  12791. /**
  12792. * Fills the matrix from direct values
  12793. * @param m00 defines value for (0, 0)
  12794. * @param m01 defines value for (0, 1)
  12795. * @param m10 defines value for (1, 0)
  12796. * @param m11 defines value for (1, 1)
  12797. * @param m20 defines value for (2, 0)
  12798. * @param m21 defines value for (2, 1)
  12799. * @returns the current modified matrix
  12800. */
  12801. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12802. this.m[0] = m00;
  12803. this.m[1] = m01;
  12804. this.m[2] = m10;
  12805. this.m[3] = m11;
  12806. this.m[4] = m20;
  12807. this.m[5] = m21;
  12808. return this;
  12809. };
  12810. /**
  12811. * Gets matrix determinant
  12812. * @returns the determinant
  12813. */
  12814. Matrix2D.prototype.determinant = function () {
  12815. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12816. };
  12817. /**
  12818. * Inverses the matrix and stores it in a target matrix
  12819. * @param result defines the target matrix
  12820. * @returns the current matrix
  12821. */
  12822. Matrix2D.prototype.invertToRef = function (result) {
  12823. var l0 = this.m[0];
  12824. var l1 = this.m[1];
  12825. var l2 = this.m[2];
  12826. var l3 = this.m[3];
  12827. var l4 = this.m[4];
  12828. var l5 = this.m[5];
  12829. var det = this.determinant();
  12830. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12831. result.m[0] = 0;
  12832. result.m[1] = 0;
  12833. result.m[2] = 0;
  12834. result.m[3] = 0;
  12835. result.m[4] = 0;
  12836. result.m[5] = 0;
  12837. return this;
  12838. }
  12839. var detDiv = 1 / det;
  12840. var det4 = l2 * l5 - l3 * l4;
  12841. var det5 = l1 * l4 - l0 * l5;
  12842. result.m[0] = l3 * detDiv;
  12843. result.m[1] = -l1 * detDiv;
  12844. result.m[2] = -l2 * detDiv;
  12845. result.m[3] = l0 * detDiv;
  12846. result.m[4] = det4 * detDiv;
  12847. result.m[5] = det5 * detDiv;
  12848. return this;
  12849. };
  12850. /**
  12851. * Multiplies the current matrix with another one
  12852. * @param other defines the second operand
  12853. * @param result defines the target matrix
  12854. * @returns the current matrix
  12855. */
  12856. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12857. var l0 = this.m[0];
  12858. var l1 = this.m[1];
  12859. var l2 = this.m[2];
  12860. var l3 = this.m[3];
  12861. var l4 = this.m[4];
  12862. var l5 = this.m[5];
  12863. var r0 = other.m[0];
  12864. var r1 = other.m[1];
  12865. var r2 = other.m[2];
  12866. var r3 = other.m[3];
  12867. var r4 = other.m[4];
  12868. var r5 = other.m[5];
  12869. result.m[0] = l0 * r0 + l1 * r2;
  12870. result.m[1] = l0 * r1 + l1 * r3;
  12871. result.m[2] = l2 * r0 + l3 * r2;
  12872. result.m[3] = l2 * r1 + l3 * r3;
  12873. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12874. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12875. return this;
  12876. };
  12877. /**
  12878. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12879. * @param x defines the x coordinate to transform
  12880. * @param y defines the x coordinate to transform
  12881. * @param result defines the target vector2
  12882. * @returns the current matrix
  12883. */
  12884. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12885. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12886. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12887. return this;
  12888. };
  12889. // Statics
  12890. /**
  12891. * Creates an identity matrix
  12892. * @returns a new matrix
  12893. */
  12894. Matrix2D.Identity = function () {
  12895. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12896. };
  12897. /**
  12898. * Creates a translation matrix and stores it in a target matrix
  12899. * @param x defines the x coordinate of the translation
  12900. * @param y defines the y coordinate of the translation
  12901. * @param result defines the target matrix
  12902. */
  12903. Matrix2D.TranslationToRef = function (x, y, result) {
  12904. result.fromValues(1, 0, 0, 1, x, y);
  12905. };
  12906. /**
  12907. * Creates a scaling matrix and stores it in a target matrix
  12908. * @param x defines the x coordinate of the scaling
  12909. * @param y defines the y coordinate of the scaling
  12910. * @param result defines the target matrix
  12911. */
  12912. Matrix2D.ScalingToRef = function (x, y, result) {
  12913. result.fromValues(x, 0, 0, y, 0, 0);
  12914. };
  12915. /**
  12916. * Creates a rotation matrix and stores it in a target matrix
  12917. * @param angle defines the rotation angle
  12918. * @param result defines the target matrix
  12919. */
  12920. Matrix2D.RotationToRef = function (angle, result) {
  12921. var s = Math.sin(angle);
  12922. var c = Math.cos(angle);
  12923. result.fromValues(c, s, -s, c, 0, 0);
  12924. };
  12925. /**
  12926. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12927. * @param tx defines the x coordinate of the translation
  12928. * @param ty defines the y coordinate of the translation
  12929. * @param angle defines the rotation angle
  12930. * @param scaleX defines the x coordinate of the scaling
  12931. * @param scaleY defines the y coordinate of the scaling
  12932. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12933. * @param result defines the target matrix
  12934. */
  12935. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12936. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12937. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12938. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12939. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12940. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12941. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12942. if (parentMatrix) {
  12943. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12944. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12945. }
  12946. else {
  12947. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12948. }
  12949. };
  12950. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12951. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12952. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12953. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12954. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12955. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12956. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12957. return Matrix2D;
  12958. }());
  12959. /***/ }),
  12960. /***/ "./2D/measure.ts":
  12961. /*!***********************!*\
  12962. !*** ./2D/measure.ts ***!
  12963. \***********************/
  12964. /*! exports provided: Measure */
  12965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12966. "use strict";
  12967. __webpack_require__.r(__webpack_exports__);
  12968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12969. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  12970. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  12971. var tmpRect = [
  12972. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12973. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12974. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12975. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12976. ];
  12977. var tmpRect2 = [
  12978. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12979. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12980. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12981. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12982. ];
  12983. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12984. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12985. /**
  12986. * Class used to store 2D control sizes
  12987. */
  12988. var Measure = /** @class */ (function () {
  12989. /**
  12990. * Creates a new measure
  12991. * @param left defines left coordinate
  12992. * @param top defines top coordinate
  12993. * @param width defines width dimension
  12994. * @param height defines height dimension
  12995. */
  12996. function Measure(
  12997. /** defines left coordinate */
  12998. left,
  12999. /** defines top coordinate */
  13000. top,
  13001. /** defines width dimension */
  13002. width,
  13003. /** defines height dimension */
  13004. height) {
  13005. this.left = left;
  13006. this.top = top;
  13007. this.width = width;
  13008. this.height = height;
  13009. }
  13010. /**
  13011. * Copy from another measure
  13012. * @param other defines the other measure to copy from
  13013. */
  13014. Measure.prototype.copyFrom = function (other) {
  13015. this.left = other.left;
  13016. this.top = other.top;
  13017. this.width = other.width;
  13018. this.height = other.height;
  13019. };
  13020. /**
  13021. * Copy from a group of 4 floats
  13022. * @param left defines left coordinate
  13023. * @param top defines top coordinate
  13024. * @param width defines width dimension
  13025. * @param height defines height dimension
  13026. */
  13027. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13028. this.left = left;
  13029. this.top = top;
  13030. this.width = width;
  13031. this.height = height;
  13032. };
  13033. /**
  13034. * Computes the axis aligned bounding box measure for two given measures
  13035. * @param a Input measure
  13036. * @param b Input measure
  13037. * @param result the resulting bounding measure
  13038. */
  13039. Measure.CombineToRef = function (a, b, result) {
  13040. var left = Math.min(a.left, b.left);
  13041. var top = Math.min(a.top, b.top);
  13042. var right = Math.max(a.left + a.width, b.left + b.width);
  13043. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13044. result.left = left;
  13045. result.top = top;
  13046. result.width = right - left;
  13047. result.height = bottom - top;
  13048. };
  13049. /**
  13050. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13051. * @param transform the matrix to transform the measure before computing the AABB
  13052. * @param result the resulting AABB
  13053. */
  13054. Measure.prototype.transformToRef = function (transform, result) {
  13055. tmpRect[0].copyFromFloats(this.left, this.top);
  13056. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  13057. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  13058. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  13059. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13060. tmpV2.copyFromFloats(0, 0);
  13061. for (var i = 0; i < 4; i++) {
  13062. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13063. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13064. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13065. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13066. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13067. }
  13068. result.left = tmpV1.x;
  13069. result.top = tmpV1.y;
  13070. result.width = tmpV2.x - tmpV1.x;
  13071. result.height = tmpV2.y - tmpV1.y;
  13072. };
  13073. /**
  13074. * Check equality between this measure and another one
  13075. * @param other defines the other measures
  13076. * @returns true if both measures are equals
  13077. */
  13078. Measure.prototype.isEqualsTo = function (other) {
  13079. if (this.left !== other.left) {
  13080. return false;
  13081. }
  13082. if (this.top !== other.top) {
  13083. return false;
  13084. }
  13085. if (this.width !== other.width) {
  13086. return false;
  13087. }
  13088. if (this.height !== other.height) {
  13089. return false;
  13090. }
  13091. return true;
  13092. };
  13093. /**
  13094. * Creates an empty measure
  13095. * @returns a new measure
  13096. */
  13097. Measure.Empty = function () {
  13098. return new Measure(0, 0, 0, 0);
  13099. };
  13100. return Measure;
  13101. }());
  13102. /***/ }),
  13103. /***/ "./2D/multiLinePoint.ts":
  13104. /*!******************************!*\
  13105. !*** ./2D/multiLinePoint.ts ***!
  13106. \******************************/
  13107. /*! exports provided: MultiLinePoint */
  13108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13109. "use strict";
  13110. __webpack_require__.r(__webpack_exports__);
  13111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13112. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13113. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13114. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13115. /**
  13116. * Class used to store a point for a MultiLine object.
  13117. * The point can be pure 2D coordinates, a mesh or a control
  13118. */
  13119. var MultiLinePoint = /** @class */ (function () {
  13120. /**
  13121. * Creates a new MultiLinePoint
  13122. * @param multiLine defines the source MultiLine object
  13123. */
  13124. function MultiLinePoint(multiLine) {
  13125. this._multiLine = multiLine;
  13126. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13127. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13128. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13129. }
  13130. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13131. /** Gets or sets x coordinate */
  13132. get: function () {
  13133. return this._x.toString(this._multiLine._host);
  13134. },
  13135. set: function (value) {
  13136. if (this._x.toString(this._multiLine._host) === value) {
  13137. return;
  13138. }
  13139. if (this._x.fromString(value)) {
  13140. this._multiLine._markAsDirty();
  13141. }
  13142. },
  13143. enumerable: true,
  13144. configurable: true
  13145. });
  13146. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13147. /** Gets or sets y coordinate */
  13148. get: function () {
  13149. return this._y.toString(this._multiLine._host);
  13150. },
  13151. set: function (value) {
  13152. if (this._y.toString(this._multiLine._host) === value) {
  13153. return;
  13154. }
  13155. if (this._y.fromString(value)) {
  13156. this._multiLine._markAsDirty();
  13157. }
  13158. },
  13159. enumerable: true,
  13160. configurable: true
  13161. });
  13162. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13163. /** Gets or sets the control associated with this point */
  13164. get: function () {
  13165. return this._control;
  13166. },
  13167. set: function (value) {
  13168. if (this._control === value) {
  13169. return;
  13170. }
  13171. if (this._control && this._controlObserver) {
  13172. this._control.onDirtyObservable.remove(this._controlObserver);
  13173. this._controlObserver = null;
  13174. }
  13175. this._control = value;
  13176. if (this._control) {
  13177. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13178. }
  13179. this._multiLine._markAsDirty();
  13180. },
  13181. enumerable: true,
  13182. configurable: true
  13183. });
  13184. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13185. /** Gets or sets the mesh associated with this point */
  13186. get: function () {
  13187. return this._mesh;
  13188. },
  13189. set: function (value) {
  13190. if (this._mesh === value) {
  13191. return;
  13192. }
  13193. if (this._mesh && this._meshObserver) {
  13194. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13195. }
  13196. this._mesh = value;
  13197. if (this._mesh) {
  13198. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13199. }
  13200. this._multiLine._markAsDirty();
  13201. },
  13202. enumerable: true,
  13203. configurable: true
  13204. });
  13205. /** Resets links */
  13206. MultiLinePoint.prototype.resetLinks = function () {
  13207. this.control = null;
  13208. this.mesh = null;
  13209. };
  13210. /**
  13211. * Gets a translation vector
  13212. * @returns the translation vector
  13213. */
  13214. MultiLinePoint.prototype.translate = function () {
  13215. this._point = this._translatePoint();
  13216. return this._point;
  13217. };
  13218. MultiLinePoint.prototype._translatePoint = function () {
  13219. if (this._mesh != null) {
  13220. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13221. }
  13222. else if (this._control != null) {
  13223. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13224. }
  13225. else {
  13226. var host = this._multiLine._host;
  13227. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13228. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13229. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13230. }
  13231. };
  13232. /** Release associated resources */
  13233. MultiLinePoint.prototype.dispose = function () {
  13234. this.resetLinks();
  13235. };
  13236. return MultiLinePoint;
  13237. }());
  13238. /***/ }),
  13239. /***/ "./2D/style.ts":
  13240. /*!*********************!*\
  13241. !*** ./2D/style.ts ***!
  13242. \*********************/
  13243. /*! exports provided: Style */
  13244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13245. "use strict";
  13246. __webpack_require__.r(__webpack_exports__);
  13247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13248. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  13249. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13250. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13251. /**
  13252. * Define a style used by control to automatically setup properties based on a template.
  13253. * Only support font related properties so far
  13254. */
  13255. var Style = /** @class */ (function () {
  13256. /**
  13257. * Creates a new style object
  13258. * @param host defines the AdvancedDynamicTexture which hosts this style
  13259. */
  13260. function Style(host) {
  13261. this._fontFamily = "Arial";
  13262. this._fontStyle = "";
  13263. this._fontWeight = "";
  13264. /** @hidden */
  13265. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13266. /**
  13267. * Observable raised when the style values are changed
  13268. */
  13269. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13270. this._host = host;
  13271. }
  13272. Object.defineProperty(Style.prototype, "fontSize", {
  13273. /**
  13274. * Gets or sets the font size
  13275. */
  13276. get: function () {
  13277. return this._fontSize.toString(this._host);
  13278. },
  13279. set: function (value) {
  13280. if (this._fontSize.toString(this._host) === value) {
  13281. return;
  13282. }
  13283. if (this._fontSize.fromString(value)) {
  13284. this.onChangedObservable.notifyObservers(this);
  13285. }
  13286. },
  13287. enumerable: true,
  13288. configurable: true
  13289. });
  13290. Object.defineProperty(Style.prototype, "fontFamily", {
  13291. /**
  13292. * Gets or sets the font family
  13293. */
  13294. get: function () {
  13295. return this._fontFamily;
  13296. },
  13297. set: function (value) {
  13298. if (this._fontFamily === value) {
  13299. return;
  13300. }
  13301. this._fontFamily = value;
  13302. this.onChangedObservable.notifyObservers(this);
  13303. },
  13304. enumerable: true,
  13305. configurable: true
  13306. });
  13307. Object.defineProperty(Style.prototype, "fontStyle", {
  13308. /**
  13309. * Gets or sets the font style
  13310. */
  13311. get: function () {
  13312. return this._fontStyle;
  13313. },
  13314. set: function (value) {
  13315. if (this._fontStyle === value) {
  13316. return;
  13317. }
  13318. this._fontStyle = value;
  13319. this.onChangedObservable.notifyObservers(this);
  13320. },
  13321. enumerable: true,
  13322. configurable: true
  13323. });
  13324. Object.defineProperty(Style.prototype, "fontWeight", {
  13325. /** Gets or sets font weight */
  13326. get: function () {
  13327. return this._fontWeight;
  13328. },
  13329. set: function (value) {
  13330. if (this._fontWeight === value) {
  13331. return;
  13332. }
  13333. this._fontWeight = value;
  13334. this.onChangedObservable.notifyObservers(this);
  13335. },
  13336. enumerable: true,
  13337. configurable: true
  13338. });
  13339. /** Dispose all associated resources */
  13340. Style.prototype.dispose = function () {
  13341. this.onChangedObservable.clear();
  13342. };
  13343. return Style;
  13344. }());
  13345. /***/ }),
  13346. /***/ "./2D/valueAndUnit.ts":
  13347. /*!****************************!*\
  13348. !*** ./2D/valueAndUnit.ts ***!
  13349. \****************************/
  13350. /*! exports provided: ValueAndUnit */
  13351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13352. "use strict";
  13353. __webpack_require__.r(__webpack_exports__);
  13354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13355. /**
  13356. * Class used to specific a value and its associated unit
  13357. */
  13358. var ValueAndUnit = /** @class */ (function () {
  13359. /**
  13360. * Creates a new ValueAndUnit
  13361. * @param value defines the value to store
  13362. * @param unit defines the unit to store
  13363. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13364. */
  13365. function ValueAndUnit(value,
  13366. /** defines the unit to store */
  13367. unit,
  13368. /** defines a boolean indicating if the value can be negative */
  13369. negativeValueAllowed) {
  13370. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13371. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13372. this.unit = unit;
  13373. this.negativeValueAllowed = negativeValueAllowed;
  13374. this._value = 1;
  13375. /**
  13376. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13377. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13378. */
  13379. this.ignoreAdaptiveScaling = false;
  13380. this._value = value;
  13381. this._originalUnit = unit;
  13382. }
  13383. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13384. /** Gets a boolean indicating if the value is a percentage */
  13385. get: function () {
  13386. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13387. },
  13388. enumerable: true,
  13389. configurable: true
  13390. });
  13391. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13392. /** Gets a boolean indicating if the value is store as pixel */
  13393. get: function () {
  13394. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13395. },
  13396. enumerable: true,
  13397. configurable: true
  13398. });
  13399. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13400. /** Gets direct internal value */
  13401. get: function () {
  13402. return this._value;
  13403. },
  13404. enumerable: true,
  13405. configurable: true
  13406. });
  13407. /**
  13408. * Gets value as pixel
  13409. * @param host defines the root host
  13410. * @param refValue defines the reference value for percentages
  13411. * @returns the value as pixel
  13412. */
  13413. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13414. if (this.isPixel) {
  13415. return this.getValue(host);
  13416. }
  13417. return this.getValue(host) * refValue;
  13418. };
  13419. /**
  13420. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13421. * @param value defines the value to store
  13422. * @param unit defines the unit to store
  13423. * @returns the current ValueAndUnit
  13424. */
  13425. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13426. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13427. this._value = value;
  13428. this.unit = unit;
  13429. return this;
  13430. };
  13431. /**
  13432. * Gets the value accordingly to its unit
  13433. * @param host defines the root host
  13434. * @returns the value
  13435. */
  13436. ValueAndUnit.prototype.getValue = function (host) {
  13437. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13438. var width = 0;
  13439. var height = 0;
  13440. if (host.idealWidth) {
  13441. width = (this._value * host.getSize().width) / host.idealWidth;
  13442. }
  13443. if (host.idealHeight) {
  13444. height = (this._value * host.getSize().height) / host.idealHeight;
  13445. }
  13446. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13447. return window.innerWidth < window.innerHeight ? width : height;
  13448. }
  13449. if (host.idealWidth) { // horizontal
  13450. return width;
  13451. }
  13452. if (host.idealHeight) { // vertical
  13453. return height;
  13454. }
  13455. }
  13456. return this._value;
  13457. };
  13458. /**
  13459. * Gets a string representation of the value
  13460. * @param host defines the root host
  13461. * @param decimals defines an optional number of decimals to display
  13462. * @returns a string
  13463. */
  13464. ValueAndUnit.prototype.toString = function (host, decimals) {
  13465. switch (this.unit) {
  13466. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13467. var percentage = this.getValue(host) * 100;
  13468. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13469. case ValueAndUnit.UNITMODE_PIXEL:
  13470. var pixels = this.getValue(host);
  13471. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13472. }
  13473. return this.unit.toString();
  13474. };
  13475. /**
  13476. * Store a value parsed from a string
  13477. * @param source defines the source string
  13478. * @returns true if the value was successfully parsed
  13479. */
  13480. ValueAndUnit.prototype.fromString = function (source) {
  13481. var match = ValueAndUnit._Regex.exec(source.toString());
  13482. if (!match || match.length === 0) {
  13483. return false;
  13484. }
  13485. var sourceValue = parseFloat(match[1]);
  13486. var sourceUnit = this._originalUnit;
  13487. if (!this.negativeValueAllowed) {
  13488. if (sourceValue < 0) {
  13489. sourceValue = 0;
  13490. }
  13491. }
  13492. if (match.length === 4) {
  13493. switch (match[3]) {
  13494. case "px":
  13495. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13496. break;
  13497. case "%":
  13498. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13499. sourceValue /= 100.0;
  13500. break;
  13501. }
  13502. }
  13503. if (sourceValue === this._value && sourceUnit === this.unit) {
  13504. return false;
  13505. }
  13506. this._value = sourceValue;
  13507. this.unit = sourceUnit;
  13508. return true;
  13509. };
  13510. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13511. /** UNITMODE_PERCENTAGE */
  13512. get: function () {
  13513. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13514. },
  13515. enumerable: true,
  13516. configurable: true
  13517. });
  13518. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13519. /** UNITMODE_PIXEL */
  13520. get: function () {
  13521. return ValueAndUnit._UNITMODE_PIXEL;
  13522. },
  13523. enumerable: true,
  13524. configurable: true
  13525. });
  13526. // Static
  13527. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13528. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13529. ValueAndUnit._UNITMODE_PIXEL = 1;
  13530. return ValueAndUnit;
  13531. }());
  13532. /***/ }),
  13533. /***/ "./2D/xmlLoader.ts":
  13534. /*!*************************!*\
  13535. !*** ./2D/xmlLoader.ts ***!
  13536. \*************************/
  13537. /*! exports provided: XmlLoader */
  13538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13539. "use strict";
  13540. __webpack_require__.r(__webpack_exports__);
  13541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13542. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  13543. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13544. /**
  13545. * Class used to load GUI via XML.
  13546. */
  13547. var XmlLoader = /** @class */ (function () {
  13548. /**
  13549. * Create a new xml loader
  13550. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13551. */
  13552. function XmlLoader(parentClass) {
  13553. if (parentClass === void 0) { parentClass = null; }
  13554. this._nodes = {};
  13555. this._nodeTypes = {
  13556. element: 1,
  13557. attribute: 2,
  13558. text: 3
  13559. };
  13560. this._isLoaded = false;
  13561. this._objectAttributes = {
  13562. "textHorizontalAlignment": 1,
  13563. "textVerticalAlignment": 2,
  13564. "horizontalAlignment": 3,
  13565. "verticalAlignment": 4,
  13566. "stretch": 5,
  13567. };
  13568. if (parentClass) {
  13569. this._parentClass = parentClass;
  13570. }
  13571. }
  13572. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13573. var element = window;
  13574. if (this._parentClass) {
  13575. element = this._parentClass;
  13576. }
  13577. var value = attributeValue;
  13578. value = value.split(".");
  13579. for (var i = 0; i < value.length; i++) {
  13580. element = element[value[i]];
  13581. }
  13582. return element;
  13583. };
  13584. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13585. var attribute = attributeName.split(".");
  13586. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13587. return className[attribute[1]];
  13588. };
  13589. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13590. if (linkParent === void 0) { linkParent = true; }
  13591. try {
  13592. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13593. var guiNode = new className();
  13594. if (parent && linkParent) {
  13595. parent.addControl(guiNode);
  13596. }
  13597. for (var i = 0; i < node.attributes.length; i++) {
  13598. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13599. continue;
  13600. }
  13601. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13602. var element = this._getChainElement(node.attributes[i].value);
  13603. guiNode[node.attributes[i].name].add(element);
  13604. continue;
  13605. }
  13606. else if (node.attributes[i].name == "linkWithMesh") {
  13607. if (this._parentClass) {
  13608. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13609. }
  13610. else {
  13611. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13612. }
  13613. }
  13614. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13615. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13616. guiNode[node.attributes[i].name] = element;
  13617. }
  13618. else if (!this._objectAttributes[node.attributes[i].name]) {
  13619. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13620. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13621. }
  13622. else {
  13623. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13624. }
  13625. }
  13626. else {
  13627. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13628. }
  13629. }
  13630. if (!node.attributes.getNamedItem("id")) {
  13631. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13632. return guiNode;
  13633. }
  13634. var id = node.attributes.getNamedItem("id").value;
  13635. if (id.startsWith("{{") && id.endsWith("}}")) {
  13636. id = this._getChainElement(id.substring(2, id.length - 2));
  13637. }
  13638. if (!this._nodes[id]) {
  13639. this._nodes[id] = guiNode;
  13640. }
  13641. else {
  13642. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13643. }
  13644. return guiNode;
  13645. }
  13646. catch (e) {
  13647. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13648. }
  13649. };
  13650. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13651. var width;
  13652. var height;
  13653. var columns;
  13654. var rows = node.children;
  13655. var cells;
  13656. var isPixel = false;
  13657. var cellNode;
  13658. var rowNumber = -1;
  13659. var columnNumber = -1;
  13660. var totalColumnsNumber = 0;
  13661. for (var i = 0; i < rows.length; i++) {
  13662. if (rows[i].nodeType != this._nodeTypes.element) {
  13663. continue;
  13664. }
  13665. if (rows[i].nodeName != "Row") {
  13666. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13667. }
  13668. rowNumber += 1;
  13669. columns = rows[i].children;
  13670. if (!rows[i].attributes.getNamedItem("height")) {
  13671. throw "XmlLoader Exception : Height must be defined for grid rows";
  13672. }
  13673. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13674. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13675. guiNode.addRowDefinition(height, isPixel);
  13676. for (var j = 0; j < columns.length; j++) {
  13677. if (columns[j].nodeType != this._nodeTypes.element) {
  13678. continue;
  13679. }
  13680. if (columns[j].nodeName != "Column") {
  13681. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13682. }
  13683. columnNumber += 1;
  13684. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13685. throw "XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.";
  13686. }
  13687. if (rowNumber == 0) {
  13688. if (!columns[j].attributes.getNamedItem("width")) {
  13689. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13690. }
  13691. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13692. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13693. guiNode.addColumnDefinition(width, isPixel);
  13694. }
  13695. cells = columns[j].children;
  13696. for (var k = 0; k < cells.length; k++) {
  13697. if (cells[k].nodeType != this._nodeTypes.element) {
  13698. continue;
  13699. }
  13700. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13701. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13702. if (cells[k].firstChild) {
  13703. this._parseXml(cells[k].firstChild, cellNode);
  13704. }
  13705. }
  13706. }
  13707. if (rowNumber == 0) {
  13708. totalColumnsNumber = columnNumber;
  13709. }
  13710. columnNumber = -1;
  13711. }
  13712. if (node.nextSibling) {
  13713. this._parseXml(node.nextSibling, parent);
  13714. }
  13715. };
  13716. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13717. if (node.firstChild) {
  13718. this._parseXml(node.firstChild, guiNode);
  13719. }
  13720. if (node.nextSibling) {
  13721. this._parseXml(node.nextSibling, parent);
  13722. }
  13723. };
  13724. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13725. if (this._parentClass) {
  13726. this._parentClass[variable] = source[iterator];
  13727. }
  13728. else {
  13729. window[variable] = source[iterator];
  13730. }
  13731. if (node.firstChild) {
  13732. this._parseXml(node.firstChild, guiNode, true);
  13733. }
  13734. };
  13735. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13736. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13737. if (!dataSource.includes(" in ")) {
  13738. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13739. }
  13740. else {
  13741. var isArray = true;
  13742. var splittedSource = dataSource.split(" in ");
  13743. if (splittedSource.length < 2) {
  13744. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13745. }
  13746. var source = splittedSource[1];
  13747. if (source.startsWith("{") && source.endsWith("}")) {
  13748. isArray = false;
  13749. }
  13750. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13751. source = source.substring(1, source.length - 1);
  13752. }
  13753. if (this._parentClass) {
  13754. source = this._parentClass[source];
  13755. }
  13756. else {
  13757. source = window[source];
  13758. }
  13759. if (isArray) {
  13760. for (var i = 0; i < source.length; i++) {
  13761. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13762. }
  13763. }
  13764. else {
  13765. for (var i in source) {
  13766. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13767. }
  13768. }
  13769. if (node.nextSibling) {
  13770. this._parseXml(node.nextSibling, parent);
  13771. }
  13772. }
  13773. };
  13774. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13775. if (generated === void 0) { generated = false; }
  13776. if (node.nodeType != this._nodeTypes.element) {
  13777. if (node.nextSibling) {
  13778. this._parseXml(node.nextSibling, parent, generated);
  13779. }
  13780. return;
  13781. }
  13782. if (generated) {
  13783. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13784. }
  13785. var guiNode = this._createGuiElement(node, parent);
  13786. if (node.nodeName == "Grid") {
  13787. this._parseGrid(node, guiNode, parent);
  13788. }
  13789. else if (!node.attributes.getNamedItem("dataSource")) {
  13790. this._parseElement(node, guiNode, parent);
  13791. }
  13792. else {
  13793. this._parseElementsFromSource(node, guiNode, parent);
  13794. }
  13795. };
  13796. /**
  13797. * Gets if the loading has finished.
  13798. * @returns whether the loading has finished or not
  13799. */
  13800. XmlLoader.prototype.isLoaded = function () {
  13801. return this._isLoaded;
  13802. };
  13803. /**
  13804. * Gets a loaded node / control by id.
  13805. * @param id the Controls id set in the xml
  13806. * @returns element of type Control
  13807. */
  13808. XmlLoader.prototype.getNodeById = function (id) {
  13809. return this._nodes[id];
  13810. };
  13811. /**
  13812. * Gets all loaded nodes / controls
  13813. * @returns Array of controls
  13814. */
  13815. XmlLoader.prototype.getNodes = function () {
  13816. return this._nodes;
  13817. };
  13818. /**
  13819. * Initiates the xml layout loading
  13820. * @param xmlFile defines the xml layout to load
  13821. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13822. * @param callback defines the callback called on layout load.
  13823. */
  13824. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13825. var xhttp = new XMLHttpRequest();
  13826. xhttp.onreadystatechange = function () {
  13827. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13828. if (!xhttp.responseXML) {
  13829. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13830. }
  13831. var xmlDoc = xhttp.responseXML.documentElement;
  13832. this._parseXml(xmlDoc.firstChild, rootNode);
  13833. this._isLoaded = true;
  13834. if (callback) {
  13835. callback();
  13836. }
  13837. }
  13838. }.bind(this);
  13839. xhttp.open("GET", xmlFile, true);
  13840. xhttp.send();
  13841. };
  13842. return XmlLoader;
  13843. }());
  13844. /***/ }),
  13845. /***/ "./3D/controls/abstractButton3D.ts":
  13846. /*!*****************************************!*\
  13847. !*** ./3D/controls/abstractButton3D.ts ***!
  13848. \*****************************************/
  13849. /*! exports provided: AbstractButton3D */
  13850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13851. "use strict";
  13852. __webpack_require__.r(__webpack_exports__);
  13853. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13854. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13855. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  13856. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13857. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13858. /**
  13859. * Class used as a root to all buttons
  13860. */
  13861. var AbstractButton3D = /** @class */ (function (_super) {
  13862. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13863. /**
  13864. * Creates a new button
  13865. * @param name defines the control name
  13866. */
  13867. function AbstractButton3D(name) {
  13868. return _super.call(this, name) || this;
  13869. }
  13870. AbstractButton3D.prototype._getTypeName = function () {
  13871. return "AbstractButton3D";
  13872. };
  13873. // Mesh association
  13874. AbstractButton3D.prototype._createNode = function (scene) {
  13875. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13876. };
  13877. return AbstractButton3D;
  13878. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13879. /***/ }),
  13880. /***/ "./3D/controls/button3D.ts":
  13881. /*!*********************************!*\
  13882. !*** ./3D/controls/button3D.ts ***!
  13883. \*********************************/
  13884. /*! exports provided: Button3D */
  13885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13886. "use strict";
  13887. __webpack_require__.r(__webpack_exports__);
  13888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13889. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13890. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13891. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13892. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13893. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13894. /**
  13895. * Class used to create a button in 3D
  13896. */
  13897. var Button3D = /** @class */ (function (_super) {
  13898. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13899. /**
  13900. * Creates a new button
  13901. * @param name defines the control name
  13902. */
  13903. function Button3D(name) {
  13904. var _this = _super.call(this, name) || this;
  13905. _this._contentResolution = 512;
  13906. _this._contentScaleRatio = 2;
  13907. // Default animations
  13908. _this.pointerEnterAnimation = function () {
  13909. if (!_this.mesh) {
  13910. return;
  13911. }
  13912. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13913. };
  13914. _this.pointerOutAnimation = function () {
  13915. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13916. };
  13917. _this.pointerDownAnimation = function () {
  13918. if (!_this.mesh) {
  13919. return;
  13920. }
  13921. _this.mesh.scaling.scaleInPlace(0.95);
  13922. };
  13923. _this.pointerUpAnimation = function () {
  13924. if (!_this.mesh) {
  13925. return;
  13926. }
  13927. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13928. };
  13929. return _this;
  13930. }
  13931. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13932. /**
  13933. * Gets or sets the texture resolution used to render content (512 by default)
  13934. */
  13935. get: function () {
  13936. return this._contentResolution;
  13937. },
  13938. set: function (value) {
  13939. if (this._contentResolution === value) {
  13940. return;
  13941. }
  13942. this._contentResolution = value;
  13943. this._resetContent();
  13944. },
  13945. enumerable: true,
  13946. configurable: true
  13947. });
  13948. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13949. /**
  13950. * Gets or sets the texture scale ratio used to render content (2 by default)
  13951. */
  13952. get: function () {
  13953. return this._contentScaleRatio;
  13954. },
  13955. set: function (value) {
  13956. if (this._contentScaleRatio === value) {
  13957. return;
  13958. }
  13959. this._contentScaleRatio = value;
  13960. this._resetContent();
  13961. },
  13962. enumerable: true,
  13963. configurable: true
  13964. });
  13965. Button3D.prototype._disposeFacadeTexture = function () {
  13966. if (this._facadeTexture) {
  13967. this._facadeTexture.dispose();
  13968. this._facadeTexture = null;
  13969. }
  13970. };
  13971. Button3D.prototype._resetContent = function () {
  13972. this._disposeFacadeTexture();
  13973. this.content = this._content;
  13974. };
  13975. Object.defineProperty(Button3D.prototype, "content", {
  13976. /**
  13977. * Gets or sets the GUI 2D content used to display the button's facade
  13978. */
  13979. get: function () {
  13980. return this._content;
  13981. },
  13982. set: function (value) {
  13983. this._content = value;
  13984. if (!this._host || !this._host.utilityLayer) {
  13985. return;
  13986. }
  13987. if (!this._facadeTexture) {
  13988. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  13989. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13990. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13991. this._facadeTexture.premulAlpha = true;
  13992. }
  13993. else {
  13994. this._facadeTexture.rootContainer.clearControls();
  13995. }
  13996. this._facadeTexture.addControl(value);
  13997. this._applyFacade(this._facadeTexture);
  13998. },
  13999. enumerable: true,
  14000. configurable: true
  14001. });
  14002. /**
  14003. * Apply the facade texture (created from the content property).
  14004. * This function can be overloaded by child classes
  14005. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14006. */
  14007. Button3D.prototype._applyFacade = function (facadeTexture) {
  14008. this._currentMaterial.emissiveTexture = facadeTexture;
  14009. };
  14010. Button3D.prototype._getTypeName = function () {
  14011. return "Button3D";
  14012. };
  14013. // Mesh association
  14014. Button3D.prototype._createNode = function (scene) {
  14015. var faceUV = new Array(6);
  14016. for (var i = 0; i < 6; i++) {
  14017. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14018. }
  14019. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14020. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14021. width: 1.0,
  14022. height: 1.0,
  14023. depth: 0.08,
  14024. faceUV: faceUV
  14025. }, scene);
  14026. return mesh;
  14027. };
  14028. Button3D.prototype._affectMaterial = function (mesh) {
  14029. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14030. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14031. mesh.material = material;
  14032. this._currentMaterial = material;
  14033. this._resetContent();
  14034. };
  14035. /**
  14036. * Releases all associated resources
  14037. */
  14038. Button3D.prototype.dispose = function () {
  14039. _super.prototype.dispose.call(this);
  14040. this._disposeFacadeTexture();
  14041. if (this._currentMaterial) {
  14042. this._currentMaterial.dispose();
  14043. }
  14044. };
  14045. return Button3D;
  14046. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14047. /***/ }),
  14048. /***/ "./3D/controls/container3D.ts":
  14049. /*!************************************!*\
  14050. !*** ./3D/controls/container3D.ts ***!
  14051. \************************************/
  14052. /*! exports provided: Container3D */
  14053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14054. "use strict";
  14055. __webpack_require__.r(__webpack_exports__);
  14056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14057. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14058. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  14059. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14060. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14061. /**
  14062. * Class used to create containers for controls
  14063. */
  14064. var Container3D = /** @class */ (function (_super) {
  14065. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14066. /**
  14067. * Creates a new container
  14068. * @param name defines the container name
  14069. */
  14070. function Container3D(name) {
  14071. var _this = _super.call(this, name) || this;
  14072. _this._blockLayout = false;
  14073. /**
  14074. * Gets the list of child controls
  14075. */
  14076. _this._children = new Array();
  14077. return _this;
  14078. }
  14079. Object.defineProperty(Container3D.prototype, "children", {
  14080. /**
  14081. * Gets the list of child controls
  14082. */
  14083. get: function () {
  14084. return this._children;
  14085. },
  14086. enumerable: true,
  14087. configurable: true
  14088. });
  14089. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14090. /**
  14091. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14092. * This is helpful to optimize layout operation when adding multiple children in a row
  14093. */
  14094. get: function () {
  14095. return this._blockLayout;
  14096. },
  14097. set: function (value) {
  14098. if (this._blockLayout === value) {
  14099. return;
  14100. }
  14101. this._blockLayout = value;
  14102. if (!this._blockLayout) {
  14103. this._arrangeChildren();
  14104. }
  14105. },
  14106. enumerable: true,
  14107. configurable: true
  14108. });
  14109. /**
  14110. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14111. * @returns the current container
  14112. */
  14113. Container3D.prototype.updateLayout = function () {
  14114. this._arrangeChildren();
  14115. return this;
  14116. };
  14117. /**
  14118. * Gets a boolean indicating if the given control is in the children of this control
  14119. * @param control defines the control to check
  14120. * @returns true if the control is in the child list
  14121. */
  14122. Container3D.prototype.containsControl = function (control) {
  14123. return this._children.indexOf(control) !== -1;
  14124. };
  14125. /**
  14126. * Adds a control to the children of this control
  14127. * @param control defines the control to add
  14128. * @returns the current container
  14129. */
  14130. Container3D.prototype.addControl = function (control) {
  14131. var index = this._children.indexOf(control);
  14132. if (index !== -1) {
  14133. return this;
  14134. }
  14135. control.parent = this;
  14136. control._host = this._host;
  14137. this._children.push(control);
  14138. if (this._host.utilityLayer) {
  14139. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14140. if (control.node) {
  14141. control.node.parent = this.node;
  14142. }
  14143. if (!this.blockLayout) {
  14144. this._arrangeChildren();
  14145. }
  14146. }
  14147. return this;
  14148. };
  14149. /**
  14150. * This function will be called everytime a new control is added
  14151. */
  14152. Container3D.prototype._arrangeChildren = function () {
  14153. };
  14154. Container3D.prototype._createNode = function (scene) {
  14155. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14156. };
  14157. /**
  14158. * Removes a control from the children of this control
  14159. * @param control defines the control to remove
  14160. * @returns the current container
  14161. */
  14162. Container3D.prototype.removeControl = function (control) {
  14163. var index = this._children.indexOf(control);
  14164. if (index !== -1) {
  14165. this._children.splice(index, 1);
  14166. control.parent = null;
  14167. control._disposeNode();
  14168. }
  14169. return this;
  14170. };
  14171. Container3D.prototype._getTypeName = function () {
  14172. return "Container3D";
  14173. };
  14174. /**
  14175. * Releases all associated resources
  14176. */
  14177. Container3D.prototype.dispose = function () {
  14178. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14179. var control = _a[_i];
  14180. control.dispose();
  14181. }
  14182. this._children = [];
  14183. _super.prototype.dispose.call(this);
  14184. };
  14185. /** Control rotation will remain unchanged */
  14186. Container3D.UNSET_ORIENTATION = 0;
  14187. /** Control will rotate to make it look at sphere central axis */
  14188. Container3D.FACEORIGIN_ORIENTATION = 1;
  14189. /** Control will rotate to make it look back at sphere central axis */
  14190. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14191. /** Control will rotate to look at z axis (0, 0, 1) */
  14192. Container3D.FACEFORWARD_ORIENTATION = 3;
  14193. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14194. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14195. return Container3D;
  14196. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14197. /***/ }),
  14198. /***/ "./3D/controls/control3D.ts":
  14199. /*!**********************************!*\
  14200. !*** ./3D/controls/control3D.ts ***!
  14201. \**********************************/
  14202. /*! exports provided: Control3D */
  14203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14204. "use strict";
  14205. __webpack_require__.r(__webpack_exports__);
  14206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14207. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  14208. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14209. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14210. /**
  14211. * Class used as base class for controls
  14212. */
  14213. var Control3D = /** @class */ (function () {
  14214. /**
  14215. * Creates a new control
  14216. * @param name defines the control name
  14217. */
  14218. function Control3D(
  14219. /** Defines the control name */
  14220. name) {
  14221. this.name = name;
  14222. this._downCount = 0;
  14223. this._enterCount = -1;
  14224. this._downPointerIds = {};
  14225. this._isVisible = true;
  14226. /**
  14227. * An event triggered when the pointer move over the control
  14228. */
  14229. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14230. /**
  14231. * An event triggered when the pointer move out of the control
  14232. */
  14233. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14234. /**
  14235. * An event triggered when the pointer taps the control
  14236. */
  14237. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14238. /**
  14239. * An event triggered when pointer is up
  14240. */
  14241. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14242. /**
  14243. * An event triggered when a control is clicked on (with a mouse)
  14244. */
  14245. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14246. /**
  14247. * An event triggered when pointer enters the control
  14248. */
  14249. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14250. // Behaviors
  14251. this._behaviors = new Array();
  14252. }
  14253. Object.defineProperty(Control3D.prototype, "position", {
  14254. /** Gets or sets the control position in world space */
  14255. get: function () {
  14256. if (!this._node) {
  14257. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14258. }
  14259. return this._node.position;
  14260. },
  14261. set: function (value) {
  14262. if (!this._node) {
  14263. return;
  14264. }
  14265. this._node.position = value;
  14266. },
  14267. enumerable: true,
  14268. configurable: true
  14269. });
  14270. Object.defineProperty(Control3D.prototype, "scaling", {
  14271. /** Gets or sets the control scaling in world space */
  14272. get: function () {
  14273. if (!this._node) {
  14274. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14275. }
  14276. return this._node.scaling;
  14277. },
  14278. set: function (value) {
  14279. if (!this._node) {
  14280. return;
  14281. }
  14282. this._node.scaling = value;
  14283. },
  14284. enumerable: true,
  14285. configurable: true
  14286. });
  14287. Object.defineProperty(Control3D.prototype, "behaviors", {
  14288. /**
  14289. * Gets the list of attached behaviors
  14290. * @see http://doc.babylonjs.com/features/behaviour
  14291. */
  14292. get: function () {
  14293. return this._behaviors;
  14294. },
  14295. enumerable: true,
  14296. configurable: true
  14297. });
  14298. /**
  14299. * Attach a behavior to the control
  14300. * @see http://doc.babylonjs.com/features/behaviour
  14301. * @param behavior defines the behavior to attach
  14302. * @returns the current control
  14303. */
  14304. Control3D.prototype.addBehavior = function (behavior) {
  14305. var _this = this;
  14306. var index = this._behaviors.indexOf(behavior);
  14307. if (index !== -1) {
  14308. return this;
  14309. }
  14310. behavior.init();
  14311. var scene = this._host.scene;
  14312. if (scene.isLoading) {
  14313. // We defer the attach when the scene will be loaded
  14314. scene.onDataLoadedObservable.addOnce(function () {
  14315. behavior.attach(_this);
  14316. });
  14317. }
  14318. else {
  14319. behavior.attach(this);
  14320. }
  14321. this._behaviors.push(behavior);
  14322. return this;
  14323. };
  14324. /**
  14325. * Remove an attached behavior
  14326. * @see http://doc.babylonjs.com/features/behaviour
  14327. * @param behavior defines the behavior to attach
  14328. * @returns the current control
  14329. */
  14330. Control3D.prototype.removeBehavior = function (behavior) {
  14331. var index = this._behaviors.indexOf(behavior);
  14332. if (index === -1) {
  14333. return this;
  14334. }
  14335. this._behaviors[index].detach();
  14336. this._behaviors.splice(index, 1);
  14337. return this;
  14338. };
  14339. /**
  14340. * Gets an attached behavior by name
  14341. * @param name defines the name of the behavior to look for
  14342. * @see http://doc.babylonjs.com/features/behaviour
  14343. * @returns null if behavior was not found else the requested behavior
  14344. */
  14345. Control3D.prototype.getBehaviorByName = function (name) {
  14346. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14347. var behavior = _a[_i];
  14348. if (behavior.name === name) {
  14349. return behavior;
  14350. }
  14351. }
  14352. return null;
  14353. };
  14354. Object.defineProperty(Control3D.prototype, "isVisible", {
  14355. /** Gets or sets a boolean indicating if the control is visible */
  14356. get: function () {
  14357. return this._isVisible;
  14358. },
  14359. set: function (value) {
  14360. if (this._isVisible === value) {
  14361. return;
  14362. }
  14363. this._isVisible = value;
  14364. var mesh = this.mesh;
  14365. if (mesh) {
  14366. mesh.setEnabled(value);
  14367. }
  14368. },
  14369. enumerable: true,
  14370. configurable: true
  14371. });
  14372. Object.defineProperty(Control3D.prototype, "typeName", {
  14373. /**
  14374. * Gets a string representing the class name
  14375. */
  14376. get: function () {
  14377. return this._getTypeName();
  14378. },
  14379. enumerable: true,
  14380. configurable: true
  14381. });
  14382. /**
  14383. * Get the current class name of the control.
  14384. * @returns current class name
  14385. */
  14386. Control3D.prototype.getClassName = function () {
  14387. return this._getTypeName();
  14388. };
  14389. Control3D.prototype._getTypeName = function () {
  14390. return "Control3D";
  14391. };
  14392. Object.defineProperty(Control3D.prototype, "node", {
  14393. /**
  14394. * Gets the transform node used by this control
  14395. */
  14396. get: function () {
  14397. return this._node;
  14398. },
  14399. enumerable: true,
  14400. configurable: true
  14401. });
  14402. Object.defineProperty(Control3D.prototype, "mesh", {
  14403. /**
  14404. * Gets the mesh used to render this control
  14405. */
  14406. get: function () {
  14407. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14408. return this._node;
  14409. }
  14410. return null;
  14411. },
  14412. enumerable: true,
  14413. configurable: true
  14414. });
  14415. /**
  14416. * Link the control as child of the given node
  14417. * @param node defines the node to link to. Use null to unlink the control
  14418. * @returns the current control
  14419. */
  14420. Control3D.prototype.linkToTransformNode = function (node) {
  14421. if (this._node) {
  14422. this._node.parent = node;
  14423. }
  14424. return this;
  14425. };
  14426. /** @hidden **/
  14427. Control3D.prototype._prepareNode = function (scene) {
  14428. if (!this._node) {
  14429. this._node = this._createNode(scene);
  14430. if (!this.node) {
  14431. return;
  14432. }
  14433. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14434. this._node.position = this.position;
  14435. this._node.scaling = this.scaling;
  14436. var mesh = this.mesh;
  14437. if (mesh) {
  14438. mesh.isPickable = true;
  14439. this._affectMaterial(mesh);
  14440. }
  14441. }
  14442. };
  14443. /**
  14444. * Node creation.
  14445. * Can be overriden by children
  14446. * @param scene defines the scene where the node must be attached
  14447. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14448. */
  14449. Control3D.prototype._createNode = function (scene) {
  14450. // Do nothing by default
  14451. return null;
  14452. };
  14453. /**
  14454. * Affect a material to the given mesh
  14455. * @param mesh defines the mesh which will represent the control
  14456. */
  14457. Control3D.prototype._affectMaterial = function (mesh) {
  14458. mesh.material = null;
  14459. };
  14460. // Pointers
  14461. /** @hidden */
  14462. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14463. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14464. };
  14465. /** @hidden */
  14466. Control3D.prototype._onPointerEnter = function (target) {
  14467. if (this._enterCount > 0) {
  14468. return false;
  14469. }
  14470. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14471. this._enterCount = 0;
  14472. }
  14473. this._enterCount++;
  14474. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14475. if (this.pointerEnterAnimation) {
  14476. this.pointerEnterAnimation();
  14477. }
  14478. return true;
  14479. };
  14480. /** @hidden */
  14481. Control3D.prototype._onPointerOut = function (target) {
  14482. this._enterCount = 0;
  14483. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14484. if (this.pointerOutAnimation) {
  14485. this.pointerOutAnimation();
  14486. }
  14487. };
  14488. /** @hidden */
  14489. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14490. if (this._downCount !== 0) {
  14491. this._downCount++;
  14492. return false;
  14493. }
  14494. this._downCount++;
  14495. this._downPointerIds[pointerId] = true;
  14496. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14497. if (this.pointerDownAnimation) {
  14498. this.pointerDownAnimation();
  14499. }
  14500. return true;
  14501. };
  14502. /** @hidden */
  14503. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14504. this._downCount--;
  14505. delete this._downPointerIds[pointerId];
  14506. if (this._downCount < 0) {
  14507. // Handle if forcePointerUp was called prior to this
  14508. this._downCount = 0;
  14509. return;
  14510. }
  14511. if (this._downCount == 0) {
  14512. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14513. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14514. }
  14515. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14516. if (this.pointerUpAnimation) {
  14517. this.pointerUpAnimation();
  14518. }
  14519. }
  14520. };
  14521. /** @hidden */
  14522. Control3D.prototype.forcePointerUp = function (pointerId) {
  14523. if (pointerId === void 0) { pointerId = null; }
  14524. if (pointerId !== null) {
  14525. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14526. }
  14527. else {
  14528. for (var key in this._downPointerIds) {
  14529. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14530. }
  14531. if (this._downCount > 0) {
  14532. this._downCount = 1;
  14533. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14534. }
  14535. }
  14536. };
  14537. /** @hidden */
  14538. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14539. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14540. this._onPointerMove(this, pickedPoint);
  14541. var previousControlOver = this._host._lastControlOver[pointerId];
  14542. if (previousControlOver && previousControlOver !== this) {
  14543. previousControlOver._onPointerOut(this);
  14544. }
  14545. if (previousControlOver !== this) {
  14546. this._onPointerEnter(this);
  14547. }
  14548. this._host._lastControlOver[pointerId] = this;
  14549. return true;
  14550. }
  14551. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14552. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14553. this._host._lastControlDown[pointerId] = this;
  14554. this._host._lastPickedControl = this;
  14555. return true;
  14556. }
  14557. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  14558. if (this._host._lastControlDown[pointerId]) {
  14559. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14560. }
  14561. delete this._host._lastControlDown[pointerId];
  14562. return true;
  14563. }
  14564. return false;
  14565. };
  14566. /** @hidden */
  14567. Control3D.prototype._disposeNode = function () {
  14568. if (this._node) {
  14569. this._node.dispose();
  14570. this._node = null;
  14571. }
  14572. };
  14573. /**
  14574. * Releases all associated resources
  14575. */
  14576. Control3D.prototype.dispose = function () {
  14577. this.onPointerDownObservable.clear();
  14578. this.onPointerEnterObservable.clear();
  14579. this.onPointerMoveObservable.clear();
  14580. this.onPointerOutObservable.clear();
  14581. this.onPointerUpObservable.clear();
  14582. this.onPointerClickObservable.clear();
  14583. this._disposeNode();
  14584. // Behaviors
  14585. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14586. var behavior = _a[_i];
  14587. behavior.detach();
  14588. }
  14589. };
  14590. return Control3D;
  14591. }());
  14592. /***/ }),
  14593. /***/ "./3D/controls/cylinderPanel.ts":
  14594. /*!**************************************!*\
  14595. !*** ./3D/controls/cylinderPanel.ts ***!
  14596. \**************************************/
  14597. /*! exports provided: CylinderPanel */
  14598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14599. "use strict";
  14600. __webpack_require__.r(__webpack_exports__);
  14601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14602. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14603. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  14604. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14605. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14606. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14607. /**
  14608. * Class used to create a container panel deployed on the surface of a cylinder
  14609. */
  14610. var CylinderPanel = /** @class */ (function (_super) {
  14611. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14612. function CylinderPanel() {
  14613. var _this = _super !== null && _super.apply(this, arguments) || this;
  14614. _this._radius = 5.0;
  14615. return _this;
  14616. }
  14617. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14618. /**
  14619. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14620. */
  14621. get: function () {
  14622. return this._radius;
  14623. },
  14624. set: function (value) {
  14625. var _this = this;
  14626. if (this._radius === value) {
  14627. return;
  14628. }
  14629. this._radius = value;
  14630. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14631. _this._arrangeChildren();
  14632. });
  14633. },
  14634. enumerable: true,
  14635. configurable: true
  14636. });
  14637. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14638. var mesh = control.mesh;
  14639. if (!mesh) {
  14640. return;
  14641. }
  14642. var newPos = this._cylindricalMapping(nodePosition);
  14643. control.position = newPos;
  14644. switch (this.orientation) {
  14645. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14646. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14647. break;
  14648. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14649. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14650. break;
  14651. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14652. break;
  14653. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14654. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14655. break;
  14656. }
  14657. };
  14658. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14659. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14660. var yAngle = (source.x / this._radius);
  14661. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14662. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14663. };
  14664. return CylinderPanel;
  14665. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14666. /***/ }),
  14667. /***/ "./3D/controls/holographicButton.ts":
  14668. /*!******************************************!*\
  14669. !*** ./3D/controls/holographicButton.ts ***!
  14670. \******************************************/
  14671. /*! exports provided: HolographicButton */
  14672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14673. "use strict";
  14674. __webpack_require__.r(__webpack_exports__);
  14675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14676. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14677. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14678. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Maths/math.vector");
  14679. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14680. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14681. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14682. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14683. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14684. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14685. /**
  14686. * Class used to create a holographic button in 3D
  14687. */
  14688. var HolographicButton = /** @class */ (function (_super) {
  14689. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14690. /**
  14691. * Creates a new button
  14692. * @param name defines the control name
  14693. */
  14694. function HolographicButton(name, shareMaterials) {
  14695. if (shareMaterials === void 0) { shareMaterials = true; }
  14696. var _this = _super.call(this, name) || this;
  14697. _this._shareMaterials = true;
  14698. _this._shareMaterials = shareMaterials;
  14699. // Default animations
  14700. _this.pointerEnterAnimation = function () {
  14701. if (!_this.mesh) {
  14702. return;
  14703. }
  14704. _this._frontPlate.setEnabled(true);
  14705. };
  14706. _this.pointerOutAnimation = function () {
  14707. if (!_this.mesh) {
  14708. return;
  14709. }
  14710. _this._frontPlate.setEnabled(false);
  14711. };
  14712. return _this;
  14713. }
  14714. HolographicButton.prototype._disposeTooltip = function () {
  14715. this._tooltipFade = null;
  14716. if (this._tooltipTextBlock) {
  14717. this._tooltipTextBlock.dispose();
  14718. }
  14719. if (this._tooltipTexture) {
  14720. this._tooltipTexture.dispose();
  14721. }
  14722. if (this._tooltipMesh) {
  14723. this._tooltipMesh.dispose();
  14724. }
  14725. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14726. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14727. };
  14728. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14729. get: function () {
  14730. return this._backPlate.renderingGroupId;
  14731. },
  14732. /**
  14733. * Rendering ground id of all the mesh in the button
  14734. */
  14735. set: function (id) {
  14736. this._backPlate.renderingGroupId = id;
  14737. this._textPlate.renderingGroupId = id;
  14738. this._frontPlate.renderingGroupId = id;
  14739. if (this._tooltipMesh) {
  14740. this._tooltipMesh.renderingGroupId = id;
  14741. }
  14742. },
  14743. enumerable: true,
  14744. configurable: true
  14745. });
  14746. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14747. get: function () {
  14748. if (this._tooltipTextBlock) {
  14749. return this._tooltipTextBlock.text;
  14750. }
  14751. return null;
  14752. },
  14753. /**
  14754. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14755. */
  14756. set: function (text) {
  14757. var _this = this;
  14758. if (!text) {
  14759. this._disposeTooltip();
  14760. return;
  14761. }
  14762. if (!this._tooltipFade) {
  14763. // Create tooltip with mesh and text
  14764. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14765. var tooltipBackground = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14766. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14767. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14768. tooltipBackground.material = mat;
  14769. tooltipBackground.isPickable = false;
  14770. this._tooltipMesh.addChild(tooltipBackground);
  14771. tooltipBackground.position.z = 0.05;
  14772. this._tooltipMesh.scaling.y = 1 / 3;
  14773. this._tooltipMesh.position.y = 0.7;
  14774. this._tooltipMesh.position.z = -0.15;
  14775. this._tooltipMesh.isPickable = false;
  14776. this._tooltipMesh.parent = this._backPlate;
  14777. // Create text texture for the tooltip
  14778. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14779. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14780. this._tooltipTextBlock.scaleY = 3;
  14781. this._tooltipTextBlock.color = "white";
  14782. this._tooltipTextBlock.fontSize = 130;
  14783. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14784. // Add hover action to tooltip
  14785. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14786. this._tooltipFade.delay = 500;
  14787. this._tooltipMesh.addBehavior(this._tooltipFade);
  14788. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14789. if (_this._tooltipFade) {
  14790. _this._tooltipFade.fadeIn(true);
  14791. }
  14792. });
  14793. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14794. if (_this._tooltipFade) {
  14795. _this._tooltipFade.fadeIn(false);
  14796. }
  14797. });
  14798. }
  14799. if (this._tooltipTextBlock) {
  14800. this._tooltipTextBlock.text = text;
  14801. }
  14802. },
  14803. enumerable: true,
  14804. configurable: true
  14805. });
  14806. Object.defineProperty(HolographicButton.prototype, "text", {
  14807. /**
  14808. * Gets or sets text for the button
  14809. */
  14810. get: function () {
  14811. return this._text;
  14812. },
  14813. set: function (value) {
  14814. if (this._text === value) {
  14815. return;
  14816. }
  14817. this._text = value;
  14818. this._rebuildContent();
  14819. },
  14820. enumerable: true,
  14821. configurable: true
  14822. });
  14823. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14824. /**
  14825. * Gets or sets the image url for the button
  14826. */
  14827. get: function () {
  14828. return this._imageUrl;
  14829. },
  14830. set: function (value) {
  14831. if (this._imageUrl === value) {
  14832. return;
  14833. }
  14834. this._imageUrl = value;
  14835. this._rebuildContent();
  14836. },
  14837. enumerable: true,
  14838. configurable: true
  14839. });
  14840. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14841. /**
  14842. * Gets the back material used by this button
  14843. */
  14844. get: function () {
  14845. return this._backMaterial;
  14846. },
  14847. enumerable: true,
  14848. configurable: true
  14849. });
  14850. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14851. /**
  14852. * Gets the front material used by this button
  14853. */
  14854. get: function () {
  14855. return this._frontMaterial;
  14856. },
  14857. enumerable: true,
  14858. configurable: true
  14859. });
  14860. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14861. /**
  14862. * Gets the plate material used by this button
  14863. */
  14864. get: function () {
  14865. return this._plateMaterial;
  14866. },
  14867. enumerable: true,
  14868. configurable: true
  14869. });
  14870. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14871. /**
  14872. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14873. */
  14874. get: function () {
  14875. return this._shareMaterials;
  14876. },
  14877. enumerable: true,
  14878. configurable: true
  14879. });
  14880. HolographicButton.prototype._getTypeName = function () {
  14881. return "HolographicButton";
  14882. };
  14883. HolographicButton.prototype._rebuildContent = function () {
  14884. this._disposeFacadeTexture();
  14885. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14886. panel.isVertical = true;
  14887. if (this._imageUrl) {
  14888. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14889. image.source = this._imageUrl;
  14890. image.paddingTop = "40px";
  14891. image.height = "180px";
  14892. image.width = "100px";
  14893. image.paddingBottom = "40px";
  14894. panel.addControl(image);
  14895. }
  14896. if (this._text) {
  14897. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14898. text.text = this._text;
  14899. text.color = "white";
  14900. text.height = "30px";
  14901. text.fontSize = 24;
  14902. panel.addControl(text);
  14903. }
  14904. if (this._frontPlate) {
  14905. this.content = panel;
  14906. }
  14907. };
  14908. // Mesh association
  14909. HolographicButton.prototype._createNode = function (scene) {
  14910. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14911. width: 1.0,
  14912. height: 1.0,
  14913. depth: 0.08
  14914. }, scene);
  14915. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14916. width: 1.0,
  14917. height: 1.0,
  14918. depth: 0.08
  14919. }, scene);
  14920. this._frontPlate.parent = this._backPlate;
  14921. this._frontPlate.position.z = -0.08;
  14922. this._frontPlate.isPickable = false;
  14923. this._frontPlate.setEnabled(false);
  14924. this._textPlate = _super.prototype._createNode.call(this, scene);
  14925. this._textPlate.parent = this._backPlate;
  14926. this._textPlate.position.z = -0.08;
  14927. this._textPlate.isPickable = false;
  14928. return this._backPlate;
  14929. };
  14930. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14931. this._plateMaterial.emissiveTexture = facadeTexture;
  14932. this._plateMaterial.opacityTexture = facadeTexture;
  14933. };
  14934. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14935. var _this = this;
  14936. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14937. this._backMaterial.renderHoverLight = true;
  14938. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14939. if (pickedPoint) {
  14940. _this._backMaterial.hoverPosition = pickedPoint;
  14941. _this._backMaterial.hoverColor.a = 1.0;
  14942. }
  14943. else {
  14944. _this._backMaterial.hoverColor.a = 0;
  14945. }
  14946. });
  14947. };
  14948. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14949. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14950. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14951. this._frontMaterial.alpha = 0.5; // Additive
  14952. this._frontMaterial.renderBorders = true;
  14953. };
  14954. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14955. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14956. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14957. };
  14958. HolographicButton.prototype._affectMaterial = function (mesh) {
  14959. // Back
  14960. if (this._shareMaterials) {
  14961. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14962. this._createBackMaterial(mesh);
  14963. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14964. }
  14965. else {
  14966. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14967. }
  14968. // Front
  14969. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14970. this._createFrontMaterial(mesh);
  14971. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14972. }
  14973. else {
  14974. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14975. }
  14976. }
  14977. else {
  14978. this._createBackMaterial(mesh);
  14979. this._createFrontMaterial(mesh);
  14980. }
  14981. this._createPlateMaterial(mesh);
  14982. this._backPlate.material = this._backMaterial;
  14983. this._frontPlate.material = this._frontMaterial;
  14984. this._textPlate.material = this._plateMaterial;
  14985. this._rebuildContent();
  14986. };
  14987. /**
  14988. * Releases all associated resources
  14989. */
  14990. HolographicButton.prototype.dispose = function () {
  14991. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14992. this._disposeTooltip();
  14993. if (!this.shareMaterials) {
  14994. this._backMaterial.dispose();
  14995. this._frontMaterial.dispose();
  14996. this._plateMaterial.dispose();
  14997. if (this._pickedPointObserver) {
  14998. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14999. this._pickedPointObserver = null;
  15000. }
  15001. }
  15002. };
  15003. return HolographicButton;
  15004. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15005. /***/ }),
  15006. /***/ "./3D/controls/index.ts":
  15007. /*!******************************!*\
  15008. !*** ./3D/controls/index.ts ***!
  15009. \******************************/
  15010. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15012. "use strict";
  15013. __webpack_require__.r(__webpack_exports__);
  15014. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15016. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15018. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15020. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15022. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15024. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15026. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15028. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15030. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15032. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15034. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15036. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15038. /***/ }),
  15039. /***/ "./3D/controls/meshButton3D.ts":
  15040. /*!*************************************!*\
  15041. !*** ./3D/controls/meshButton3D.ts ***!
  15042. \*************************************/
  15043. /*! exports provided: MeshButton3D */
  15044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15045. "use strict";
  15046. __webpack_require__.r(__webpack_exports__);
  15047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15049. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15050. /**
  15051. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15052. */
  15053. var MeshButton3D = /** @class */ (function (_super) {
  15054. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15055. /**
  15056. * Creates a new 3D button based on a mesh
  15057. * @param mesh mesh to become a 3D button
  15058. * @param name defines the control name
  15059. */
  15060. function MeshButton3D(mesh, name) {
  15061. var _this = _super.call(this, name) || this;
  15062. _this._currentMesh = mesh;
  15063. /**
  15064. * Provides a default behavior on hover/out & up/down
  15065. * Override those function to create your own desired behavior specific to your mesh
  15066. */
  15067. _this.pointerEnterAnimation = function () {
  15068. if (!_this.mesh) {
  15069. return;
  15070. }
  15071. _this.mesh.scaling.scaleInPlace(1.1);
  15072. };
  15073. _this.pointerOutAnimation = function () {
  15074. if (!_this.mesh) {
  15075. return;
  15076. }
  15077. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15078. };
  15079. _this.pointerDownAnimation = function () {
  15080. if (!_this.mesh) {
  15081. return;
  15082. }
  15083. _this.mesh.scaling.scaleInPlace(0.95);
  15084. };
  15085. _this.pointerUpAnimation = function () {
  15086. if (!_this.mesh) {
  15087. return;
  15088. }
  15089. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15090. };
  15091. return _this;
  15092. }
  15093. MeshButton3D.prototype._getTypeName = function () {
  15094. return "MeshButton3D";
  15095. };
  15096. // Mesh association
  15097. MeshButton3D.prototype._createNode = function (scene) {
  15098. var _this = this;
  15099. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15100. mesh.metadata = _this;
  15101. });
  15102. return this._currentMesh;
  15103. };
  15104. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15105. };
  15106. return MeshButton3D;
  15107. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15108. /***/ }),
  15109. /***/ "./3D/controls/planePanel.ts":
  15110. /*!***********************************!*\
  15111. !*** ./3D/controls/planePanel.ts ***!
  15112. \***********************************/
  15113. /*! exports provided: PlanePanel */
  15114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15115. "use strict";
  15116. __webpack_require__.r(__webpack_exports__);
  15117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15118. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15119. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  15120. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15121. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15122. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15123. /**
  15124. * Class used to create a container panel deployed on the surface of a plane
  15125. */
  15126. var PlanePanel = /** @class */ (function (_super) {
  15127. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15128. function PlanePanel() {
  15129. return _super !== null && _super.apply(this, arguments) || this;
  15130. }
  15131. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15132. var mesh = control.mesh;
  15133. if (!mesh) {
  15134. return;
  15135. }
  15136. control.position = nodePosition.clone();
  15137. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15138. target.copyFrom(nodePosition);
  15139. switch (this.orientation) {
  15140. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15141. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15142. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15143. mesh.lookAt(target);
  15144. break;
  15145. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15146. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15147. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15148. mesh.lookAt(target);
  15149. break;
  15150. }
  15151. };
  15152. return PlanePanel;
  15153. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15154. /***/ }),
  15155. /***/ "./3D/controls/scatterPanel.ts":
  15156. /*!*************************************!*\
  15157. !*** ./3D/controls/scatterPanel.ts ***!
  15158. \*************************************/
  15159. /*! exports provided: ScatterPanel */
  15160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15161. "use strict";
  15162. __webpack_require__.r(__webpack_exports__);
  15163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15164. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15165. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15166. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15167. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15168. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15169. /**
  15170. * Class used to create a container panel where items get randomized planar mapping
  15171. */
  15172. var ScatterPanel = /** @class */ (function (_super) {
  15173. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15174. function ScatterPanel() {
  15175. var _this = _super !== null && _super.apply(this, arguments) || this;
  15176. _this._iteration = 100.0;
  15177. return _this;
  15178. }
  15179. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15180. /**
  15181. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15182. */
  15183. get: function () {
  15184. return this._iteration;
  15185. },
  15186. set: function (value) {
  15187. var _this = this;
  15188. if (this._iteration === value) {
  15189. return;
  15190. }
  15191. this._iteration = value;
  15192. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15193. _this._arrangeChildren();
  15194. });
  15195. },
  15196. enumerable: true,
  15197. configurable: true
  15198. });
  15199. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15200. var mesh = control.mesh;
  15201. var newPos = this._scatterMapping(nodePosition);
  15202. if (!mesh) {
  15203. return;
  15204. }
  15205. switch (this.orientation) {
  15206. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15207. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15208. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15209. break;
  15210. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15211. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15212. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15213. break;
  15214. }
  15215. control.position = newPos;
  15216. };
  15217. ScatterPanel.prototype._scatterMapping = function (source) {
  15218. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15219. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15220. return source;
  15221. };
  15222. ScatterPanel.prototype._finalProcessing = function () {
  15223. var meshes = [];
  15224. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15225. var child = _a[_i];
  15226. if (!child.mesh) {
  15227. continue;
  15228. }
  15229. meshes.push(child.mesh);
  15230. }
  15231. for (var count = 0; count < this._iteration; count++) {
  15232. meshes.sort(function (a, b) {
  15233. var distance1 = a.position.lengthSquared();
  15234. var distance2 = b.position.lengthSquared();
  15235. if (distance1 < distance2) {
  15236. return 1;
  15237. }
  15238. else if (distance1 > distance2) {
  15239. return -1;
  15240. }
  15241. return 0;
  15242. });
  15243. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15244. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15245. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15246. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15247. for (var i = 0; i < meshes.length - 1; i++) {
  15248. for (var j = i + 1; j < meshes.length; j++) {
  15249. if (i != j) {
  15250. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15251. // Ignore Z axis
  15252. difference2D.x = difference.x;
  15253. difference2D.y = difference.y;
  15254. var combinedRadius = cellSize;
  15255. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15256. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15257. distance -= minSeparation;
  15258. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15259. difference2D.normalize();
  15260. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15261. meshes[j].position.addInPlace(difference);
  15262. meshes[i].position.subtractInPlace(difference);
  15263. }
  15264. }
  15265. }
  15266. }
  15267. }
  15268. };
  15269. return ScatterPanel;
  15270. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15271. /***/ }),
  15272. /***/ "./3D/controls/spherePanel.ts":
  15273. /*!************************************!*\
  15274. !*** ./3D/controls/spherePanel.ts ***!
  15275. \************************************/
  15276. /*! exports provided: SpherePanel */
  15277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15278. "use strict";
  15279. __webpack_require__.r(__webpack_exports__);
  15280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15281. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15282. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15283. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15284. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15285. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15286. /**
  15287. * Class used to create a container panel deployed on the surface of a sphere
  15288. */
  15289. var SpherePanel = /** @class */ (function (_super) {
  15290. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15291. function SpherePanel() {
  15292. var _this = _super !== null && _super.apply(this, arguments) || this;
  15293. _this._radius = 5.0;
  15294. return _this;
  15295. }
  15296. Object.defineProperty(SpherePanel.prototype, "radius", {
  15297. /**
  15298. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15299. */
  15300. get: function () {
  15301. return this._radius;
  15302. },
  15303. set: function (value) {
  15304. var _this = this;
  15305. if (this._radius === value) {
  15306. return;
  15307. }
  15308. this._radius = value;
  15309. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15310. _this._arrangeChildren();
  15311. });
  15312. },
  15313. enumerable: true,
  15314. configurable: true
  15315. });
  15316. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15317. var mesh = control.mesh;
  15318. if (!mesh) {
  15319. return;
  15320. }
  15321. var newPos = this._sphericalMapping(nodePosition);
  15322. control.position = newPos;
  15323. switch (this.orientation) {
  15324. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15325. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15326. break;
  15327. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15328. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15329. break;
  15330. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15331. break;
  15332. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15333. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15334. break;
  15335. }
  15336. };
  15337. SpherePanel.prototype._sphericalMapping = function (source) {
  15338. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15339. var xAngle = (source.y / this._radius);
  15340. var yAngle = -(source.x / this._radius);
  15341. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15342. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15343. };
  15344. return SpherePanel;
  15345. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15346. /***/ }),
  15347. /***/ "./3D/controls/stackPanel3D.ts":
  15348. /*!*************************************!*\
  15349. !*** ./3D/controls/stackPanel3D.ts ***!
  15350. \*************************************/
  15351. /*! exports provided: StackPanel3D */
  15352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15353. "use strict";
  15354. __webpack_require__.r(__webpack_exports__);
  15355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15356. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15357. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15358. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15359. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15360. /**
  15361. * Class used to create a stack panel in 3D on XY plane
  15362. */
  15363. var StackPanel3D = /** @class */ (function (_super) {
  15364. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15365. /**
  15366. * Creates new StackPanel
  15367. * @param isVertical
  15368. */
  15369. function StackPanel3D(isVertical) {
  15370. if (isVertical === void 0) { isVertical = false; }
  15371. var _this = _super.call(this) || this;
  15372. _this._isVertical = false;
  15373. /**
  15374. * Gets or sets the distance between elements
  15375. */
  15376. _this.margin = 0.1;
  15377. _this._isVertical = isVertical;
  15378. return _this;
  15379. }
  15380. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15381. /**
  15382. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15383. */
  15384. get: function () {
  15385. return this._isVertical;
  15386. },
  15387. set: function (value) {
  15388. var _this = this;
  15389. if (this._isVertical === value) {
  15390. return;
  15391. }
  15392. this._isVertical = value;
  15393. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15394. _this._arrangeChildren();
  15395. });
  15396. },
  15397. enumerable: true,
  15398. configurable: true
  15399. });
  15400. StackPanel3D.prototype._arrangeChildren = function () {
  15401. var width = 0;
  15402. var height = 0;
  15403. var controlCount = 0;
  15404. var extendSizes = [];
  15405. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15406. // Measure
  15407. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15408. var child = _a[_i];
  15409. if (!child.mesh) {
  15410. continue;
  15411. }
  15412. controlCount++;
  15413. child.mesh.computeWorldMatrix(true);
  15414. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15415. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15416. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15417. extendSizes.push(extendSize);
  15418. if (this._isVertical) {
  15419. height += extendSize.y;
  15420. }
  15421. else {
  15422. width += extendSize.x;
  15423. }
  15424. }
  15425. if (this._isVertical) {
  15426. height += (controlCount - 1) * this.margin / 2;
  15427. }
  15428. else {
  15429. width += (controlCount - 1) * this.margin / 2;
  15430. }
  15431. // Arrange
  15432. var offset;
  15433. if (this._isVertical) {
  15434. offset = -height;
  15435. }
  15436. else {
  15437. offset = -width;
  15438. }
  15439. var index = 0;
  15440. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15441. var child = _c[_b];
  15442. if (!child.mesh) {
  15443. continue;
  15444. }
  15445. controlCount--;
  15446. var extendSize = extendSizes[index++];
  15447. if (this._isVertical) {
  15448. child.position.y = offset + extendSize.y;
  15449. child.position.x = 0;
  15450. offset += extendSize.y * 2;
  15451. }
  15452. else {
  15453. child.position.x = offset + extendSize.x;
  15454. child.position.y = 0;
  15455. offset += extendSize.x * 2;
  15456. }
  15457. offset += (controlCount > 0 ? this.margin : 0);
  15458. }
  15459. };
  15460. return StackPanel3D;
  15461. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15462. /***/ }),
  15463. /***/ "./3D/controls/volumeBasedPanel.ts":
  15464. /*!*****************************************!*\
  15465. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15466. \*****************************************/
  15467. /*! exports provided: VolumeBasedPanel */
  15468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15469. "use strict";
  15470. __webpack_require__.r(__webpack_exports__);
  15471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15473. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15474. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15475. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15476. /**
  15477. * Abstract class used to create a container panel deployed on the surface of a volume
  15478. */
  15479. var VolumeBasedPanel = /** @class */ (function (_super) {
  15480. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15481. /**
  15482. * Creates new VolumeBasedPanel
  15483. */
  15484. function VolumeBasedPanel() {
  15485. var _this = _super.call(this) || this;
  15486. _this._columns = 10;
  15487. _this._rows = 0;
  15488. _this._rowThenColum = true;
  15489. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15490. /**
  15491. * Gets or sets the distance between elements
  15492. */
  15493. _this.margin = 0;
  15494. return _this;
  15495. }
  15496. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15497. /**
  15498. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15499. * | Value | Type | Description |
  15500. * | ----- | ----------------------------------- | ----------- |
  15501. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15502. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15503. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15504. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15505. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15506. */
  15507. get: function () {
  15508. return this._orientation;
  15509. },
  15510. set: function (value) {
  15511. var _this = this;
  15512. if (this._orientation === value) {
  15513. return;
  15514. }
  15515. this._orientation = value;
  15516. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15517. _this._arrangeChildren();
  15518. });
  15519. },
  15520. enumerable: true,
  15521. configurable: true
  15522. });
  15523. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15524. /**
  15525. * Gets or sets the number of columns requested (10 by default).
  15526. * The panel will automatically compute the number of rows based on number of child controls.
  15527. */
  15528. get: function () {
  15529. return this._columns;
  15530. },
  15531. set: function (value) {
  15532. var _this = this;
  15533. if (this._columns === value) {
  15534. return;
  15535. }
  15536. this._columns = value;
  15537. this._rowThenColum = true;
  15538. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15539. _this._arrangeChildren();
  15540. });
  15541. },
  15542. enumerable: true,
  15543. configurable: true
  15544. });
  15545. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15546. /**
  15547. * Gets or sets a the number of rows requested.
  15548. * The panel will automatically compute the number of columns based on number of child controls.
  15549. */
  15550. get: function () {
  15551. return this._rows;
  15552. },
  15553. set: function (value) {
  15554. var _this = this;
  15555. if (this._rows === value) {
  15556. return;
  15557. }
  15558. this._rows = value;
  15559. this._rowThenColum = false;
  15560. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15561. _this._arrangeChildren();
  15562. });
  15563. },
  15564. enumerable: true,
  15565. configurable: true
  15566. });
  15567. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15568. this._cellWidth = 0;
  15569. this._cellHeight = 0;
  15570. var rows = 0;
  15571. var columns = 0;
  15572. var controlCount = 0;
  15573. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15574. // Measure
  15575. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15576. var child = _a[_i];
  15577. if (!child.mesh) {
  15578. continue;
  15579. }
  15580. controlCount++;
  15581. child.mesh.computeWorldMatrix(true);
  15582. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15583. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15584. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15585. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15586. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15587. diff.scaleInPlace(0.5);
  15588. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15589. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15590. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15591. }
  15592. this._cellWidth += this.margin * 2;
  15593. this._cellHeight += this.margin * 2;
  15594. // Arrange
  15595. if (this._rowThenColum) {
  15596. columns = this._columns;
  15597. rows = Math.ceil(controlCount / this._columns);
  15598. }
  15599. else {
  15600. rows = this._rows;
  15601. columns = Math.ceil(controlCount / this._rows);
  15602. }
  15603. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15604. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15605. var nodeGrid = [];
  15606. var cellCounter = 0;
  15607. if (this._rowThenColum) {
  15608. for (var r = 0; r < rows; r++) {
  15609. for (var c = 0; c < columns; c++) {
  15610. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  15611. cellCounter++;
  15612. if (cellCounter > controlCount) {
  15613. break;
  15614. }
  15615. }
  15616. }
  15617. }
  15618. else {
  15619. for (var c = 0; c < columns; c++) {
  15620. for (var r = 0; r < rows; r++) {
  15621. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  15622. cellCounter++;
  15623. if (cellCounter > controlCount) {
  15624. break;
  15625. }
  15626. }
  15627. }
  15628. }
  15629. cellCounter = 0;
  15630. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15631. var child = _c[_b];
  15632. if (!child.mesh) {
  15633. continue;
  15634. }
  15635. this._mapGridNode(child, nodeGrid[cellCounter]);
  15636. cellCounter++;
  15637. }
  15638. this._finalProcessing();
  15639. };
  15640. /** Child classes can implement this function to provide additional processing */
  15641. VolumeBasedPanel.prototype._finalProcessing = function () {
  15642. };
  15643. return VolumeBasedPanel;
  15644. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15645. /***/ }),
  15646. /***/ "./3D/gui3DManager.ts":
  15647. /*!****************************!*\
  15648. !*** ./3D/gui3DManager.ts ***!
  15649. \****************************/
  15650. /*! exports provided: GUI3DManager */
  15651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15652. "use strict";
  15653. __webpack_require__.r(__webpack_exports__);
  15654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15655. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  15656. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15657. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15658. /**
  15659. * Class used to manage 3D user interface
  15660. * @see http://doc.babylonjs.com/how_to/gui3d
  15661. */
  15662. var GUI3DManager = /** @class */ (function () {
  15663. /**
  15664. * Creates a new GUI3DManager
  15665. * @param scene
  15666. */
  15667. function GUI3DManager(scene) {
  15668. var _this = this;
  15669. /** @hidden */
  15670. this._lastControlOver = {};
  15671. /** @hidden */
  15672. this._lastControlDown = {};
  15673. /**
  15674. * Observable raised when the point picked by the pointer events changed
  15675. */
  15676. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15677. // Shared resources
  15678. /** @hidden */
  15679. this._sharedMaterials = {};
  15680. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15681. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15682. _this._sceneDisposeObserver = null;
  15683. _this._utilityLayer = null;
  15684. _this.dispose();
  15685. });
  15686. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15687. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15688. this._utilityLayer.pickUtilitySceneFirst = false;
  15689. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15690. return mesh && mesh.metadata && mesh.metadata._node;
  15691. };
  15692. // Root
  15693. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15694. this._rootContainer._host = this;
  15695. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15696. // Events
  15697. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15698. _this._handlePointerOut(pointerId, true);
  15699. });
  15700. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15701. _this._doPicking(pi);
  15702. });
  15703. // Scene
  15704. this._utilityLayer.utilityLayerScene.autoClear = false;
  15705. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15706. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15707. }
  15708. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15709. /** Gets the hosting scene */
  15710. get: function () {
  15711. return this._scene;
  15712. },
  15713. enumerable: true,
  15714. configurable: true
  15715. });
  15716. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15717. /** Gets associated utility layer */
  15718. get: function () {
  15719. return this._utilityLayer;
  15720. },
  15721. enumerable: true,
  15722. configurable: true
  15723. });
  15724. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15725. var previousControlOver = this._lastControlOver[pointerId];
  15726. if (previousControlOver) {
  15727. previousControlOver._onPointerOut(previousControlOver);
  15728. delete this._lastControlOver[pointerId];
  15729. }
  15730. if (isPointerUp) {
  15731. if (this._lastControlDown[pointerId]) {
  15732. this._lastControlDown[pointerId].forcePointerUp();
  15733. delete this._lastControlDown[pointerId];
  15734. }
  15735. }
  15736. this.onPickedPointChangedObservable.notifyObservers(null);
  15737. };
  15738. GUI3DManager.prototype._doPicking = function (pi) {
  15739. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15740. return false;
  15741. }
  15742. var pointerEvent = (pi.event);
  15743. var pointerId = pointerEvent.pointerId || 0;
  15744. var buttonIndex = pointerEvent.button;
  15745. var pickingInfo = pi.pickInfo;
  15746. if (!pickingInfo || !pickingInfo.hit) {
  15747. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15748. return false;
  15749. }
  15750. var control = (pickingInfo.pickedMesh.metadata);
  15751. if (pickingInfo.pickedPoint) {
  15752. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15753. }
  15754. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15755. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15756. if (this._lastControlOver[pointerId]) {
  15757. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15758. }
  15759. delete this._lastControlOver[pointerId];
  15760. }
  15761. }
  15762. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15763. if (this._lastControlDown[pointerEvent.pointerId]) {
  15764. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15765. delete this._lastControlDown[pointerEvent.pointerId];
  15766. }
  15767. if (pointerEvent.pointerType === "touch") {
  15768. this._handlePointerOut(pointerId, false);
  15769. }
  15770. }
  15771. return true;
  15772. };
  15773. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15774. /**
  15775. * Gets the root container
  15776. */
  15777. get: function () {
  15778. return this._rootContainer;
  15779. },
  15780. enumerable: true,
  15781. configurable: true
  15782. });
  15783. /**
  15784. * Gets a boolean indicating if the given control is in the root child list
  15785. * @param control defines the control to check
  15786. * @returns true if the control is in the root child list
  15787. */
  15788. GUI3DManager.prototype.containsControl = function (control) {
  15789. return this._rootContainer.containsControl(control);
  15790. };
  15791. /**
  15792. * Adds a control to the root child list
  15793. * @param control defines the control to add
  15794. * @returns the current manager
  15795. */
  15796. GUI3DManager.prototype.addControl = function (control) {
  15797. this._rootContainer.addControl(control);
  15798. return this;
  15799. };
  15800. /**
  15801. * Removes a control from the root child list
  15802. * @param control defines the control to remove
  15803. * @returns the current container
  15804. */
  15805. GUI3DManager.prototype.removeControl = function (control) {
  15806. this._rootContainer.removeControl(control);
  15807. return this;
  15808. };
  15809. /**
  15810. * Releases all associated resources
  15811. */
  15812. GUI3DManager.prototype.dispose = function () {
  15813. this._rootContainer.dispose();
  15814. for (var materialName in this._sharedMaterials) {
  15815. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15816. continue;
  15817. }
  15818. this._sharedMaterials[materialName].dispose();
  15819. }
  15820. this._sharedMaterials = {};
  15821. if (this._pointerOutObserver && this._utilityLayer) {
  15822. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15823. this._pointerOutObserver = null;
  15824. }
  15825. this.onPickedPointChangedObservable.clear();
  15826. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15827. if (utilityLayerScene) {
  15828. if (this._pointerObserver) {
  15829. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15830. this._pointerObserver = null;
  15831. }
  15832. }
  15833. if (this._scene) {
  15834. if (this._sceneDisposeObserver) {
  15835. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15836. this._sceneDisposeObserver = null;
  15837. }
  15838. }
  15839. if (this._utilityLayer) {
  15840. this._utilityLayer.dispose();
  15841. }
  15842. };
  15843. return GUI3DManager;
  15844. }());
  15845. /***/ }),
  15846. /***/ "./3D/index.ts":
  15847. /*!*********************!*\
  15848. !*** ./3D/index.ts ***!
  15849. \*********************/
  15850. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  15851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15852. "use strict";
  15853. __webpack_require__.r(__webpack_exports__);
  15854. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15867. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15870. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15872. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15874. /***/ }),
  15875. /***/ "./3D/materials/fluentMaterial.ts":
  15876. /*!****************************************!*\
  15877. !*** ./3D/materials/fluentMaterial.ts ***!
  15878. \****************************************/
  15879. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15880. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15881. "use strict";
  15882. __webpack_require__.r(__webpack_exports__);
  15883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15885. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15886. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math.vector");
  15887. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15888. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15889. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15890. /** @hidden */
  15891. var FluentMaterialDefines = /** @class */ (function (_super) {
  15892. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15893. function FluentMaterialDefines() {
  15894. var _this = _super.call(this) || this;
  15895. _this.INNERGLOW = false;
  15896. _this.BORDER = false;
  15897. _this.HOVERLIGHT = false;
  15898. _this.TEXTURE = false;
  15899. _this.rebuild();
  15900. return _this;
  15901. }
  15902. return FluentMaterialDefines;
  15903. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15904. /**
  15905. * Class used to render controls with fluent desgin
  15906. */
  15907. var FluentMaterial = /** @class */ (function (_super) {
  15908. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15909. /**
  15910. * Creates a new Fluent material
  15911. * @param name defines the name of the material
  15912. * @param scene defines the hosting scene
  15913. */
  15914. function FluentMaterial(name, scene) {
  15915. var _this = _super.call(this, name, scene) || this;
  15916. /**
  15917. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15918. */
  15919. _this.innerGlowColorIntensity = 0.5;
  15920. /**
  15921. * Gets or sets the inner glow color (white by default)
  15922. */
  15923. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15924. /**
  15925. * Gets or sets alpha value (default is 1.0)
  15926. */
  15927. _this.alpha = 1.0;
  15928. /**
  15929. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15930. */
  15931. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15932. /**
  15933. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15934. */
  15935. _this.renderBorders = false;
  15936. /**
  15937. * Gets or sets border width (default is 0.5)
  15938. */
  15939. _this.borderWidth = 0.5;
  15940. /**
  15941. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15942. */
  15943. _this.edgeSmoothingValue = 0.02;
  15944. /**
  15945. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15946. */
  15947. _this.borderMinValue = 0.1;
  15948. /**
  15949. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15950. */
  15951. _this.renderHoverLight = false;
  15952. /**
  15953. * Gets or sets the radius used to render the hover light (default is 1.0)
  15954. */
  15955. _this.hoverRadius = 1.0;
  15956. /**
  15957. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15958. */
  15959. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15960. /**
  15961. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15962. */
  15963. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15964. return _this;
  15965. }
  15966. FluentMaterial.prototype.needAlphaBlending = function () {
  15967. return this.alpha !== 1.0;
  15968. };
  15969. FluentMaterial.prototype.needAlphaTesting = function () {
  15970. return false;
  15971. };
  15972. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15973. return null;
  15974. };
  15975. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15976. if (this.isFrozen) {
  15977. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15978. return true;
  15979. }
  15980. }
  15981. if (!subMesh._materialDefines) {
  15982. subMesh._materialDefines = new FluentMaterialDefines();
  15983. }
  15984. var scene = this.getScene();
  15985. var defines = subMesh._materialDefines;
  15986. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15987. if (defines._renderId === scene.getRenderId()) {
  15988. return true;
  15989. }
  15990. }
  15991. if (defines._areTexturesDirty) {
  15992. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15993. defines.BORDER = this.renderBorders;
  15994. defines.HOVERLIGHT = this.renderHoverLight;
  15995. if (this._albedoTexture) {
  15996. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15997. return false;
  15998. }
  15999. else {
  16000. defines.TEXTURE = true;
  16001. }
  16002. }
  16003. else {
  16004. defines.TEXTURE = false;
  16005. }
  16006. }
  16007. var engine = scene.getEngine();
  16008. // Get correct effect
  16009. if (defines.isDirty) {
  16010. defines.markAsProcessed();
  16011. scene.resetCachedMaterial();
  16012. //Attributes
  16013. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16014. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16015. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16016. var shaderName = "fluent";
  16017. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16018. "hoverColor", "hoverPosition", "hoverRadius"
  16019. ];
  16020. var samplers = ["albedoSampler"];
  16021. var uniformBuffers = new Array();
  16022. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16023. uniformsNames: uniforms,
  16024. uniformBuffersNames: uniformBuffers,
  16025. samplers: samplers,
  16026. defines: defines,
  16027. maxSimultaneousLights: 4
  16028. });
  16029. var join = defines.toString();
  16030. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16031. attributes: attribs,
  16032. uniformsNames: uniforms,
  16033. uniformBuffersNames: uniformBuffers,
  16034. samplers: samplers,
  16035. defines: join,
  16036. fallbacks: null,
  16037. onCompiled: this.onCompiled,
  16038. onError: this.onError,
  16039. indexParameters: { maxSimultaneousLights: 4 }
  16040. }, engine));
  16041. }
  16042. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16043. return false;
  16044. }
  16045. defines._renderId = scene.getRenderId();
  16046. subMesh.effect._wasPreviouslyReady = true;
  16047. return true;
  16048. };
  16049. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16050. var scene = this.getScene();
  16051. var defines = subMesh._materialDefines;
  16052. if (!defines) {
  16053. return;
  16054. }
  16055. var effect = subMesh.effect;
  16056. if (!effect) {
  16057. return;
  16058. }
  16059. this._activeEffect = effect;
  16060. // Matrices
  16061. this.bindOnlyWorldMatrix(world);
  16062. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16063. if (this._mustRebind(scene, effect)) {
  16064. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16065. if (defines.INNERGLOW) {
  16066. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16067. }
  16068. if (defines.BORDER) {
  16069. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16070. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16071. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16072. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16073. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16074. }
  16075. if (defines.HOVERLIGHT) {
  16076. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16077. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16078. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16079. }
  16080. if (defines.TEXTURE) {
  16081. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16082. }
  16083. }
  16084. this._afterBind(mesh, this._activeEffect);
  16085. };
  16086. FluentMaterial.prototype.getActiveTextures = function () {
  16087. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16088. return activeTextures;
  16089. };
  16090. FluentMaterial.prototype.hasTexture = function (texture) {
  16091. if (_super.prototype.hasTexture.call(this, texture)) {
  16092. return true;
  16093. }
  16094. return false;
  16095. };
  16096. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16097. _super.prototype.dispose.call(this, forceDisposeEffect);
  16098. };
  16099. FluentMaterial.prototype.clone = function (name) {
  16100. var _this = this;
  16101. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16102. };
  16103. FluentMaterial.prototype.serialize = function () {
  16104. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16105. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16106. return serializationObject;
  16107. };
  16108. FluentMaterial.prototype.getClassName = function () {
  16109. return "FluentMaterial";
  16110. };
  16111. // Statics
  16112. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16113. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16114. };
  16115. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16116. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16117. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16118. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16119. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16120. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16121. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16122. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16123. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16124. ], FluentMaterial.prototype, "alpha", void 0);
  16125. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16126. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16127. ], FluentMaterial.prototype, "albedoColor", void 0);
  16128. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16129. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16130. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16131. ], FluentMaterial.prototype, "renderBorders", void 0);
  16132. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16133. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16134. ], FluentMaterial.prototype, "borderWidth", void 0);
  16135. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16136. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16137. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16138. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16139. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16140. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16141. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16142. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16143. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16144. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16145. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16146. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16147. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16148. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16149. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16150. ], FluentMaterial.prototype, "hoverColor", void 0);
  16151. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16152. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16153. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16154. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16155. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16156. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16157. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16158. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16159. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16160. return FluentMaterial;
  16161. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16162. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16163. /***/ }),
  16164. /***/ "./3D/materials/index.ts":
  16165. /*!*******************************!*\
  16166. !*** ./3D/materials/index.ts ***!
  16167. \*******************************/
  16168. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16170. "use strict";
  16171. __webpack_require__.r(__webpack_exports__);
  16172. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16175. /***/ }),
  16176. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16177. /*!*************************************************!*\
  16178. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16179. \*************************************************/
  16180. /*! exports provided: fluentPixelShader */
  16181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16182. "use strict";
  16183. __webpack_require__.r(__webpack_exports__);
  16184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16185. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16186. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16187. var name = 'fluentPixelShader';
  16188. var shader = "precision highp float;\nvarying vec2 vUV;\nuniform vec4 albedoColor;\n#ifdef INNERGLOW\nuniform vec4 innerGlowColor;\n#endif\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float edgeSmoothingValue;\nuniform float borderMinValue;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\nuniform vec3 hoverPosition;\nuniform vec4 hoverColor;\nuniform float hoverRadius;\n#endif\n#ifdef TEXTURE\nuniform sampler2D albedoSampler;\n#endif\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\n#ifdef TEXTURE\nalbedo=texture2D(albedoSampler,vUV).rgb;\n#endif\n#ifdef HOVERLIGHT\nfloat pointToHover=(1.0-clamp(length(hoverPosition-worldPosition)/hoverRadius,0.,1.))*hoverColor.a;\nalbedo=clamp(albedo+hoverColor.rgb*pointToHover,0.,1.);\n#else\nfloat pointToHover=1.0;\n#endif\n#ifdef BORDER\nfloat borderPower=10.0;\nfloat inverseBorderPower=1.0/borderPower;\nvec3 borderColor=albedo*borderPower;\nvec2 distanceToEdge;\ndistanceToEdge.x=abs(vUV.x-0.5)*2.0;\ndistanceToEdge.y=abs(vUV.y-0.5)*2.0;\nfloat borderValue=max(smoothstep(scaleInfo.x-edgeSmoothingValue,scaleInfo.x+edgeSmoothingValue,distanceToEdge.x),\nsmoothstep(scaleInfo.y-edgeSmoothingValue,scaleInfo.y+edgeSmoothingValue,distanceToEdge.y));\nborderColor=borderColor*borderValue*max(borderMinValue*inverseBorderPower,pointToHover);\nalbedo+=borderColor;\nalpha=max(alpha,borderValue);\n#endif\n#ifdef INNERGLOW\n\nvec2 uvGlow=(vUV-vec2(0.5,0.5))*(innerGlowColor.a*2.0);\nuvGlow=uvGlow*uvGlow;\nuvGlow=uvGlow*uvGlow;\nalbedo+=mix(vec3(0.0,0.0,0.0),innerGlowColor.rgb,uvGlow.x+uvGlow.y);\n#endif\ngl_FragColor=vec4(albedo,alpha);\n}";
  16189. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16190. /** @hidden */
  16191. var fluentPixelShader = { name: name, shader: shader };
  16192. /***/ }),
  16193. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16194. /*!***********************************************!*\
  16195. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16196. \***********************************************/
  16197. /*! exports provided: fluentVertexShader */
  16198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16199. "use strict";
  16200. __webpack_require__.r(__webpack_exports__);
  16201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16202. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16203. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16204. var name = 'fluentVertexShader';
  16205. var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nuniform mat4 world;\nuniform mat4 viewProjection;\nvarying vec2 vUV;\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float borderWidth;\nuniform vec3 scaleFactor;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\n#endif\nvoid main(void) {\nvUV=uv;\n#ifdef BORDER\nvec3 scale=scaleFactor;\nfloat minScale=min(min(scale.x,scale.y),scale.z);\nfloat maxScale=max(max(scale.x,scale.y),scale.z);\nfloat minOverMiddleScale=minScale/(scale.x+scale.y+scale.z-minScale-maxScale);\nfloat areaYZ=scale.y*scale.z;\nfloat areaXZ=scale.x*scale.z;\nfloat areaXY=scale.x*scale.y;\nfloat scaledBorderWidth=borderWidth;\nif (abs(normal.x) == 1.0)\n{\nscale.x=scale.y;\nscale.y=scale.z;\nif (areaYZ>areaXZ && areaYZ>areaXY)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse if (abs(normal.y) == 1.0)\n{\nscale.x=scale.z;\nif (areaXZ>areaXY && areaXZ>areaYZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse\n{\nif (areaXY>areaYZ && areaXY>areaXZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nfloat scaleRatio=min(scale.x,scale.y)/max(scale.x,scale.y);\nif (scale.x>scale.y)\n{\nscaleInfo.x=1.0-(scaledBorderWidth*scaleRatio);\nscaleInfo.y=1.0-scaledBorderWidth;\n}\nelse\n{\nscaleInfo.x=1.0-scaledBorderWidth;\nscaleInfo.y=1.0-(scaledBorderWidth*scaleRatio);\n}\n#endif\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef HOVERLIGHT\nworldPosition=worldPos.xyz;\n#endif\ngl_Position=viewProjection*worldPos;\n}\n";
  16206. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16207. /** @hidden */
  16208. var fluentVertexShader = { name: name, shader: shader };
  16209. /***/ }),
  16210. /***/ "./3D/vector3WithInfo.ts":
  16211. /*!*******************************!*\
  16212. !*** ./3D/vector3WithInfo.ts ***!
  16213. \*******************************/
  16214. /*! exports provided: Vector3WithInfo */
  16215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16216. "use strict";
  16217. __webpack_require__.r(__webpack_exports__);
  16218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16219. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16220. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  16221. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16222. /**
  16223. * Class used to transport Vector3 information for pointer events
  16224. */
  16225. var Vector3WithInfo = /** @class */ (function (_super) {
  16226. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16227. /**
  16228. * Creates a new Vector3WithInfo
  16229. * @param source defines the vector3 data to transport
  16230. * @param buttonIndex defines the current mouse button index
  16231. */
  16232. function Vector3WithInfo(source,
  16233. /** defines the current mouse button index */
  16234. buttonIndex) {
  16235. if (buttonIndex === void 0) { buttonIndex = 0; }
  16236. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16237. _this.buttonIndex = buttonIndex;
  16238. return _this;
  16239. }
  16240. return Vector3WithInfo;
  16241. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16242. /***/ }),
  16243. /***/ "./index.ts":
  16244. /*!******************!*\
  16245. !*** ./index.ts ***!
  16246. \******************/
  16247. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16249. "use strict";
  16250. __webpack_require__.r(__webpack_exports__);
  16251. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16293. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16310. /***/ }),
  16311. /***/ "./legacy/legacy.ts":
  16312. /*!**************************!*\
  16313. !*** ./legacy/legacy.ts ***!
  16314. \**************************/
  16315. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16316. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16317. "use strict";
  16318. __webpack_require__.r(__webpack_exports__);
  16319. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16377. /**
  16378. * Legacy support, defining window.BABYLON.GUI (global variable).
  16379. *
  16380. * This is the entry point for the UMD module.
  16381. * The entry point for a future ESM package should be index.ts
  16382. */
  16383. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16384. if (typeof globalObject !== "undefined") {
  16385. globalObject.BABYLON = globalObject.BABYLON || {};
  16386. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16387. }
  16388. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16389. /***/ }),
  16390. /***/ "babylonjs/Maths/math.vector":
  16391. /*!****************************************************************************************************!*\
  16392. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16393. \****************************************************************************************************/
  16394. /*! no static exports found */
  16395. /***/ (function(module, exports) {
  16396. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__;
  16397. /***/ })
  16398. /******/ });
  16399. });
  16400. //# sourceMappingURL=babylon.gui.js.map