babylon.gui.js 753 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292
  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_Misc_perfCounter__) {
  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. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  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__, "__createBinding", function() { return __createBinding; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation.
  131. Permission to use, copy, modify, and/or distribute this software for any
  132. purpose with or without fee is hereby granted.
  133. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  134. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  135. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  136. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  137. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  138. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  139. PERFORMANCE OF THIS SOFTWARE.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  169. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  170. t[p[i]] = s[p[i]];
  171. }
  172. return t;
  173. }
  174. function __decorate(decorators, target, key, desc) {
  175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  177. 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;
  178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  179. }
  180. function __param(paramIndex, decorator) {
  181. return function (target, key) { decorator(target, key, paramIndex); }
  182. }
  183. function __metadata(metadataKey, metadataValue) {
  184. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  185. }
  186. function __awaiter(thisArg, _arguments, P, generator) {
  187. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  188. return new (P || (P = Promise))(function (resolve, reject) {
  189. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  190. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  191. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  192. step((generator = generator.apply(thisArg, _arguments || [])).next());
  193. });
  194. }
  195. function __generator(thisArg, body) {
  196. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  197. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  198. function verb(n) { return function (v) { return step([n, v]); }; }
  199. function step(op) {
  200. if (f) throw new TypeError("Generator is already executing.");
  201. while (_) try {
  202. 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;
  203. if (y = 0, t) op = [op[0] & 2, t.value];
  204. switch (op[0]) {
  205. case 0: case 1: t = op; break;
  206. case 4: _.label++; return { value: op[1], done: false };
  207. case 5: _.label++; y = op[1]; op = [0]; continue;
  208. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  209. default:
  210. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  211. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  212. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  213. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  214. if (t[2]) _.ops.pop();
  215. _.trys.pop(); continue;
  216. }
  217. op = body.call(thisArg, _);
  218. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  219. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  220. }
  221. }
  222. var __createBinding = Object.create ? (function(o, m, k, k2) {
  223. if (k2 === undefined) k2 = k;
  224. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  225. }) : (function(o, m, k, k2) {
  226. if (k2 === undefined) k2 = k;
  227. o[k2] = m[k];
  228. });
  229. function __exportStar(m, exports) {
  230. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  231. }
  232. function __values(o) {
  233. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  234. if (m) return m.call(o);
  235. if (o && typeof o.length === "number") return {
  236. next: function () {
  237. if (o && i >= o.length) o = void 0;
  238. return { value: o && o[i++], done: !o };
  239. }
  240. };
  241. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  242. }
  243. function __read(o, n) {
  244. var m = typeof Symbol === "function" && o[Symbol.iterator];
  245. if (!m) return o;
  246. var i = m.call(o), r, ar = [], e;
  247. try {
  248. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  249. }
  250. catch (error) { e = { error: error }; }
  251. finally {
  252. try {
  253. if (r && !r.done && (m = i["return"])) m.call(i);
  254. }
  255. finally { if (e) throw e.error; }
  256. }
  257. return ar;
  258. }
  259. function __spread() {
  260. for (var ar = [], i = 0; i < arguments.length; i++)
  261. ar = ar.concat(__read(arguments[i]));
  262. return ar;
  263. }
  264. function __spreadArrays() {
  265. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  266. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  267. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  268. r[k] = a[j];
  269. return r;
  270. };
  271. function __await(v) {
  272. return this instanceof __await ? (this.v = v, this) : new __await(v);
  273. }
  274. function __asyncGenerator(thisArg, _arguments, generator) {
  275. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  276. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  277. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  278. 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); }); }; }
  279. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  280. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  281. function fulfill(value) { resume("next", value); }
  282. function reject(value) { resume("throw", value); }
  283. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  284. }
  285. function __asyncDelegator(o) {
  286. var i, p;
  287. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  288. 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; }
  289. }
  290. function __asyncValues(o) {
  291. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  292. var m = o[Symbol.asyncIterator], i;
  293. 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);
  294. 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); }); }; }
  295. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  296. }
  297. function __makeTemplateObject(cooked, raw) {
  298. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  299. return cooked;
  300. };
  301. var __setModuleDefault = Object.create ? (function(o, v) {
  302. Object.defineProperty(o, "default", { enumerable: true, value: v });
  303. }) : function(o, v) {
  304. o["default"] = v;
  305. };
  306. function __importStar(mod) {
  307. if (mod && mod.__esModule) return mod;
  308. var result = {};
  309. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./2D/adtInstrumentation.ts":
  354. /*!**********************************!*\
  355. !*** ./2D/adtInstrumentation.ts ***!
  356. \**********************************/
  357. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  362. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  363. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  364. /**
  365. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  366. */
  367. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  368. /**
  369. * Instantiates a new advanced dynamic texture instrumentation.
  370. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  371. * @param texture Defines the AdvancedDynamicTexture to instrument
  372. */
  373. function AdvancedDynamicTextureInstrumentation(
  374. /**
  375. * Define the instrumented AdvancedDynamicTexture.
  376. */
  377. texture) {
  378. this.texture = texture;
  379. this._captureRenderTime = false;
  380. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  381. this._captureLayoutTime = false;
  382. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  383. // Observers
  384. this._onBeginRenderObserver = null;
  385. this._onEndRenderObserver = null;
  386. this._onBeginLayoutObserver = null;
  387. this._onEndLayoutObserver = null;
  388. }
  389. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  390. // Properties
  391. /**
  392. * Gets the perf counter used to capture render time
  393. */
  394. get: function () {
  395. return this._renderTime;
  396. },
  397. enumerable: false,
  398. configurable: true
  399. });
  400. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  401. /**
  402. * Gets the perf counter used to capture layout time
  403. */
  404. get: function () {
  405. return this._layoutTime;
  406. },
  407. enumerable: false,
  408. configurable: true
  409. });
  410. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  411. /**
  412. * Enable or disable the render time capture
  413. */
  414. get: function () {
  415. return this._captureRenderTime;
  416. },
  417. set: function (value) {
  418. var _this = this;
  419. if (value === this._captureRenderTime) {
  420. return;
  421. }
  422. this._captureRenderTime = value;
  423. if (value) {
  424. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  425. _this._renderTime.beginMonitoring();
  426. });
  427. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  428. _this._renderTime.endMonitoring(true);
  429. });
  430. }
  431. else {
  432. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  433. this._onBeginRenderObserver = null;
  434. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  435. this._onEndRenderObserver = null;
  436. }
  437. },
  438. enumerable: false,
  439. configurable: true
  440. });
  441. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  442. /**
  443. * Enable or disable the layout time capture
  444. */
  445. get: function () {
  446. return this._captureLayoutTime;
  447. },
  448. set: function (value) {
  449. var _this = this;
  450. if (value === this._captureLayoutTime) {
  451. return;
  452. }
  453. this._captureLayoutTime = value;
  454. if (value) {
  455. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  456. _this._layoutTime.beginMonitoring();
  457. });
  458. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  459. _this._layoutTime.endMonitoring(true);
  460. });
  461. }
  462. else {
  463. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  464. this._onBeginLayoutObserver = null;
  465. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  466. this._onEndLayoutObserver = null;
  467. }
  468. },
  469. enumerable: false,
  470. configurable: true
  471. });
  472. /**
  473. * Dispose and release associated resources.
  474. */
  475. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  476. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  477. this._onBeginRenderObserver = null;
  478. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  479. this._onEndRenderObserver = null;
  480. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  481. this._onBeginLayoutObserver = null;
  482. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  483. this._onEndLayoutObserver = null;
  484. this.texture = null;
  485. };
  486. return AdvancedDynamicTextureInstrumentation;
  487. }());
  488. /***/ }),
  489. /***/ "./2D/advancedDynamicTexture.ts":
  490. /*!**************************************!*\
  491. !*** ./2D/advancedDynamicTexture.ts ***!
  492. \**************************************/
  493. /*! exports provided: AdvancedDynamicTexture */
  494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  495. "use strict";
  496. __webpack_require__.r(__webpack_exports__);
  497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  499. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  500. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  501. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  502. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  503. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  504. /**
  505. * Class used to create texture to support 2D GUI elements
  506. * @see https://doc.babylonjs.com/how_to/gui
  507. */
  508. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  509. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  510. /**
  511. * Creates a new AdvancedDynamicTexture
  512. * @param name defines the name of the texture
  513. * @param width defines the width of the texture
  514. * @param height defines the height of the texture
  515. * @param scene defines the hosting scene
  516. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  517. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  518. */
  519. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  520. if (width === void 0) { width = 0; }
  521. if (height === void 0) { height = 0; }
  522. if (generateMipMaps === void 0) { generateMipMaps = false; }
  523. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  524. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  525. _this._isDirty = false;
  526. /** @hidden */
  527. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  528. /** @hidden */
  529. _this._lastControlOver = {};
  530. /** @hidden */
  531. _this._lastControlDown = {};
  532. /** @hidden */
  533. _this._capturingControl = {};
  534. /** @hidden */
  535. _this._linkedControls = new Array();
  536. _this._isFullscreen = false;
  537. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  538. _this._idealWidth = 0;
  539. _this._idealHeight = 0;
  540. _this._useSmallestIdeal = false;
  541. _this._renderAtIdealSize = false;
  542. _this._blockNextFocusCheck = false;
  543. _this._renderScale = 1;
  544. _this._cursorChanged = false;
  545. _this._defaultMousePointerId = 0;
  546. /** @hidden */
  547. _this._numLayoutCalls = 0;
  548. /** @hidden */
  549. _this._numRenderCalls = 0;
  550. /**
  551. * Define type to string to ensure compatibility across browsers
  552. * Safari doesn't support DataTransfer constructor
  553. */
  554. _this._clipboardData = "";
  555. /**
  556. * Observable event triggered each time an clipboard event is received from the rendering canvas
  557. */
  558. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  559. /**
  560. * Observable event triggered each time a pointer down is intercepted by a control
  561. */
  562. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  563. /**
  564. * Observable event triggered before layout is evaluated
  565. */
  566. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  567. /**
  568. * Observable event triggered after the layout was evaluated
  569. */
  570. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  571. /**
  572. * Observable event triggered before the texture is rendered
  573. */
  574. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  575. /**
  576. * Observable event triggered after the texture was rendered
  577. */
  578. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  579. /**
  580. * Gets or sets a boolean defining if alpha is stored as premultiplied
  581. */
  582. _this.premulAlpha = false;
  583. _this._useInvalidateRectOptimization = true;
  584. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  585. _this._invalidatedRectangle = null;
  586. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  587. /** @hidden */
  588. _this.onClipboardCopy = function (rawEvt) {
  589. var evt = rawEvt;
  590. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  591. _this.onClipboardObservable.notifyObservers(ev);
  592. evt.preventDefault();
  593. };
  594. /** @hidden */
  595. _this.onClipboardCut = function (rawEvt) {
  596. var evt = rawEvt;
  597. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  598. _this.onClipboardObservable.notifyObservers(ev);
  599. evt.preventDefault();
  600. };
  601. /** @hidden */
  602. _this.onClipboardPaste = function (rawEvt) {
  603. var evt = rawEvt;
  604. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  605. _this.onClipboardObservable.notifyObservers(ev);
  606. evt.preventDefault();
  607. };
  608. scene = _this.getScene();
  609. if (!scene || !_this._texture) {
  610. return _this;
  611. }
  612. _this._rootElement = scene.getEngine().getInputElement();
  613. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  614. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  615. if (!_this._focusedControl) {
  616. return;
  617. }
  618. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  619. _this._focusedControl.processKeyboard(info.event);
  620. }
  621. info.skipOnPointerObservable = true;
  622. });
  623. _this._rootContainer._link(_this);
  624. _this.hasAlpha = true;
  625. if (!width || !height) {
  626. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  627. _this._onResize();
  628. }
  629. _this._texture.isReady = true;
  630. return _this;
  631. }
  632. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  633. /** Gets the number of layout calls made the last time the ADT has been rendered */
  634. get: function () {
  635. return this._numLayoutCalls;
  636. },
  637. enumerable: false,
  638. configurable: true
  639. });
  640. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  641. /** Gets the number of render calls made the last time the ADT has been rendered */
  642. get: function () {
  643. return this._numRenderCalls;
  644. },
  645. enumerable: false,
  646. configurable: true
  647. });
  648. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  649. /**
  650. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  651. * Useful when you want more antialiasing
  652. */
  653. get: function () {
  654. return this._renderScale;
  655. },
  656. set: function (value) {
  657. if (value === this._renderScale) {
  658. return;
  659. }
  660. this._renderScale = value;
  661. this._onResize();
  662. },
  663. enumerable: false,
  664. configurable: true
  665. });
  666. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  667. /** Gets or sets the background color */
  668. get: function () {
  669. return this._background;
  670. },
  671. set: function (value) {
  672. if (this._background === value) {
  673. return;
  674. }
  675. this._background = value;
  676. this.markAsDirty();
  677. },
  678. enumerable: false,
  679. configurable: true
  680. });
  681. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  682. /**
  683. * Gets or sets the ideal width used to design controls.
  684. * The GUI will then rescale everything accordingly
  685. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  686. */
  687. get: function () {
  688. return this._idealWidth;
  689. },
  690. set: function (value) {
  691. if (this._idealWidth === value) {
  692. return;
  693. }
  694. this._idealWidth = value;
  695. this.markAsDirty();
  696. this._rootContainer._markAllAsDirty();
  697. },
  698. enumerable: false,
  699. configurable: true
  700. });
  701. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  702. /**
  703. * Gets or sets the ideal height used to design controls.
  704. * The GUI will then rescale everything accordingly
  705. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  706. */
  707. get: function () {
  708. return this._idealHeight;
  709. },
  710. set: function (value) {
  711. if (this._idealHeight === value) {
  712. return;
  713. }
  714. this._idealHeight = value;
  715. this.markAsDirty();
  716. this._rootContainer._markAllAsDirty();
  717. },
  718. enumerable: false,
  719. configurable: true
  720. });
  721. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  722. /**
  723. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  724. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  725. */
  726. get: function () {
  727. return this._useSmallestIdeal;
  728. },
  729. set: function (value) {
  730. if (this._useSmallestIdeal === value) {
  731. return;
  732. }
  733. this._useSmallestIdeal = value;
  734. this.markAsDirty();
  735. this._rootContainer._markAllAsDirty();
  736. },
  737. enumerable: false,
  738. configurable: true
  739. });
  740. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  741. /**
  742. * Gets or sets a boolean indicating if adaptive scaling must be used
  743. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  744. */
  745. get: function () {
  746. return this._renderAtIdealSize;
  747. },
  748. set: function (value) {
  749. if (this._renderAtIdealSize === value) {
  750. return;
  751. }
  752. this._renderAtIdealSize = value;
  753. this._onResize();
  754. },
  755. enumerable: false,
  756. configurable: true
  757. });
  758. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  759. /**
  760. * Gets the ratio used when in "ideal mode"
  761. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  762. * */
  763. get: function () {
  764. var rwidth = 0;
  765. var rheight = 0;
  766. if (this._idealWidth) {
  767. rwidth = (this.getSize().width) / this._idealWidth;
  768. }
  769. if (this._idealHeight) {
  770. rheight = (this.getSize().height) / this._idealHeight;
  771. }
  772. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  773. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  774. }
  775. if (this._idealWidth) { // horizontal
  776. return rwidth;
  777. }
  778. if (this._idealHeight) { // vertical
  779. return rheight;
  780. }
  781. return 1;
  782. },
  783. enumerable: false,
  784. configurable: true
  785. });
  786. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  787. /**
  788. * Gets the underlying layer used to render the texture when in fullscreen mode
  789. */
  790. get: function () {
  791. return this._layerToDispose;
  792. },
  793. enumerable: false,
  794. configurable: true
  795. });
  796. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  797. /**
  798. * Gets the root container control
  799. */
  800. get: function () {
  801. return this._rootContainer;
  802. },
  803. enumerable: false,
  804. configurable: true
  805. });
  806. /**
  807. * Returns an array containing the root container.
  808. * This is mostly used to let the Inspector introspects the ADT
  809. * @returns an array containing the rootContainer
  810. */
  811. AdvancedDynamicTexture.prototype.getChildren = function () {
  812. return [this._rootContainer];
  813. };
  814. /**
  815. * Will return all controls that are inside this texture
  816. * @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
  817. * @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
  818. * @return all child controls
  819. */
  820. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  821. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  822. };
  823. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  824. /**
  825. * Gets or sets the current focused control
  826. */
  827. get: function () {
  828. return this._focusedControl;
  829. },
  830. set: function (control) {
  831. if (this._focusedControl == control) {
  832. return;
  833. }
  834. if (this._focusedControl) {
  835. this._focusedControl.onBlur();
  836. }
  837. if (control) {
  838. control.onFocus();
  839. }
  840. this._focusedControl = control;
  841. },
  842. enumerable: false,
  843. configurable: true
  844. });
  845. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  846. /**
  847. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  848. */
  849. get: function () {
  850. if (!this.layer) {
  851. return true;
  852. }
  853. return (!this.layer.isBackground);
  854. },
  855. set: function (value) {
  856. if (!this.layer) {
  857. return;
  858. }
  859. if (this.layer.isBackground === !value) {
  860. return;
  861. }
  862. this.layer.isBackground = !value;
  863. },
  864. enumerable: false,
  865. configurable: true
  866. });
  867. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  868. /**
  869. * Gets or set information about clipboardData
  870. */
  871. get: function () {
  872. return this._clipboardData;
  873. },
  874. set: function (value) {
  875. this._clipboardData = value;
  876. },
  877. enumerable: false,
  878. configurable: true
  879. });
  880. /**
  881. * Get the current class name of the texture useful for serialization or dynamic coding.
  882. * @returns "AdvancedDynamicTexture"
  883. */
  884. AdvancedDynamicTexture.prototype.getClassName = function () {
  885. return "AdvancedDynamicTexture";
  886. };
  887. /**
  888. * Function used to execute a function on all controls
  889. * @param func defines the function to execute
  890. * @param container defines the container where controls belong. If null the root container will be used
  891. */
  892. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  893. if (!container) {
  894. container = this._rootContainer;
  895. }
  896. func(container);
  897. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  898. var child = _a[_i];
  899. if (child.children) {
  900. this.executeOnAllControls(func, child);
  901. continue;
  902. }
  903. func(child);
  904. }
  905. };
  906. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  907. /**
  908. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  909. */
  910. get: function () {
  911. return this._useInvalidateRectOptimization;
  912. },
  913. set: function (value) {
  914. this._useInvalidateRectOptimization = value;
  915. },
  916. enumerable: false,
  917. configurable: true
  918. });
  919. /**
  920. * Invalidates a rectangle area on the gui texture
  921. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  922. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  923. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  924. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  925. */
  926. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  927. if (!this._useInvalidateRectOptimization) {
  928. return;
  929. }
  930. if (!this._invalidatedRectangle) {
  931. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  932. }
  933. else {
  934. // Compute intersection
  935. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  936. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  937. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  938. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  939. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  940. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  941. }
  942. };
  943. /**
  944. * Marks the texture as dirty forcing a complete update
  945. */
  946. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  947. this._isDirty = true;
  948. };
  949. /**
  950. * Helper function used to create a new style
  951. * @returns a new style
  952. * @see https://doc.babylonjs.com/how_to/gui#styles
  953. */
  954. AdvancedDynamicTexture.prototype.createStyle = function () {
  955. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  956. };
  957. /**
  958. * Adds a new control to the root container
  959. * @param control defines the control to add
  960. * @returns the current texture
  961. */
  962. AdvancedDynamicTexture.prototype.addControl = function (control) {
  963. this._rootContainer.addControl(control);
  964. return this;
  965. };
  966. /**
  967. * Removes a control from the root container
  968. * @param control defines the control to remove
  969. * @returns the current texture
  970. */
  971. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  972. this._rootContainer.removeControl(control);
  973. return this;
  974. };
  975. /**
  976. * Release all resources
  977. */
  978. AdvancedDynamicTexture.prototype.dispose = function () {
  979. var scene = this.getScene();
  980. if (!scene) {
  981. return;
  982. }
  983. this._rootElement = null;
  984. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  985. if (this._resizeObserver) {
  986. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  987. }
  988. if (this._pointerMoveObserver) {
  989. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  990. }
  991. if (this._pointerObserver) {
  992. scene.onPointerObservable.remove(this._pointerObserver);
  993. }
  994. if (this._preKeyboardObserver) {
  995. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  996. }
  997. if (this._canvasPointerOutObserver) {
  998. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  999. }
  1000. if (this._layerToDispose) {
  1001. this._layerToDispose.texture = null;
  1002. this._layerToDispose.dispose();
  1003. this._layerToDispose = null;
  1004. }
  1005. this._rootContainer.dispose();
  1006. this.onClipboardObservable.clear();
  1007. this.onControlPickedObservable.clear();
  1008. this.onBeginRenderObservable.clear();
  1009. this.onEndRenderObservable.clear();
  1010. this.onBeginLayoutObservable.clear();
  1011. this.onEndLayoutObservable.clear();
  1012. _super.prototype.dispose.call(this);
  1013. };
  1014. AdvancedDynamicTexture.prototype._onResize = function () {
  1015. var scene = this.getScene();
  1016. if (!scene) {
  1017. return;
  1018. }
  1019. // Check size
  1020. var engine = scene.getEngine();
  1021. var textureSize = this.getSize();
  1022. var renderWidth = engine.getRenderWidth() * this._renderScale;
  1023. var renderHeight = engine.getRenderHeight() * this._renderScale;
  1024. if (this._renderAtIdealSize) {
  1025. if (this._idealWidth) {
  1026. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  1027. renderWidth = this._idealWidth;
  1028. }
  1029. else if (this._idealHeight) {
  1030. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1031. renderHeight = this._idealHeight;
  1032. }
  1033. }
  1034. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1035. this.scaleTo(renderWidth, renderHeight);
  1036. this.markAsDirty();
  1037. if (this._idealWidth || this._idealHeight) {
  1038. this._rootContainer._markAllAsDirty();
  1039. }
  1040. }
  1041. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1042. };
  1043. /** @hidden */
  1044. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1045. var engine = scene.getEngine();
  1046. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1047. };
  1048. /**
  1049. * Get screen coordinates for a vector3
  1050. * @param position defines the position to project
  1051. * @param worldMatrix defines the world matrix to use
  1052. * @returns the projected position
  1053. */
  1054. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1055. var scene = this.getScene();
  1056. if (!scene) {
  1057. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1058. }
  1059. var globalViewport = this._getGlobalViewport(scene);
  1060. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1061. projectedPosition.scaleInPlace(this.renderScale);
  1062. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1063. };
  1064. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1065. if (this._layerToDispose) {
  1066. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1067. return;
  1068. }
  1069. }
  1070. if (this._isFullscreen && this._linkedControls.length) {
  1071. var scene = this.getScene();
  1072. if (!scene) {
  1073. return;
  1074. }
  1075. var globalViewport = this._getGlobalViewport(scene);
  1076. var _loop_1 = function (control) {
  1077. if (!control.isVisible) {
  1078. return "continue";
  1079. }
  1080. var mesh = control._linkedMesh;
  1081. if (!mesh || mesh.isDisposed()) {
  1082. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1083. control.linkWithMesh(null);
  1084. });
  1085. return "continue";
  1086. }
  1087. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1088. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1089. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1090. control.notRenderable = true;
  1091. return "continue";
  1092. }
  1093. control.notRenderable = false;
  1094. // Account for RenderScale.
  1095. projectedPosition.scaleInPlace(this_1.renderScale);
  1096. control._moveToProjectedPosition(projectedPosition);
  1097. };
  1098. var this_1 = this;
  1099. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1100. var control = _a[_i];
  1101. _loop_1(control);
  1102. }
  1103. }
  1104. if (!this._isDirty && !this._rootContainer.isDirty) {
  1105. return;
  1106. }
  1107. this._isDirty = false;
  1108. this._render();
  1109. this.update(true, this.premulAlpha);
  1110. };
  1111. AdvancedDynamicTexture.prototype._render = function () {
  1112. var textureSize = this.getSize();
  1113. var renderWidth = textureSize.width;
  1114. var renderHeight = textureSize.height;
  1115. var context = this.getContext();
  1116. context.font = "18px Arial";
  1117. context.strokeStyle = "white";
  1118. // Layout
  1119. this.onBeginLayoutObservable.notifyObservers(this);
  1120. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1121. this._numLayoutCalls = 0;
  1122. this._rootContainer._layout(measure, context);
  1123. this.onEndLayoutObservable.notifyObservers(this);
  1124. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1125. // Clear
  1126. if (this._invalidatedRectangle) {
  1127. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1128. }
  1129. else {
  1130. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1131. }
  1132. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1133. if (this._background) {
  1134. context.save();
  1135. context.fillStyle = this._background;
  1136. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1137. context.restore();
  1138. }
  1139. // Render
  1140. this.onBeginRenderObservable.notifyObservers(this);
  1141. this._numRenderCalls = 0;
  1142. this._rootContainer._render(context, this._invalidatedRectangle);
  1143. this.onEndRenderObservable.notifyObservers(this);
  1144. this._invalidatedRectangle = null;
  1145. };
  1146. /** @hidden */
  1147. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1148. if (this._rootElement) {
  1149. this._rootElement.style.cursor = cursor;
  1150. this._cursorChanged = true;
  1151. }
  1152. };
  1153. /** @hidden */
  1154. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1155. this._lastControlDown[pointerId] = control;
  1156. this.onControlPickedObservable.notifyObservers(control);
  1157. };
  1158. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1159. var scene = this.getScene();
  1160. if (!scene) {
  1161. return;
  1162. }
  1163. var engine = scene.getEngine();
  1164. var textureSize = this.getSize();
  1165. if (this._isFullscreen) {
  1166. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1167. var viewport = camera.viewport;
  1168. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1169. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1170. }
  1171. if (this._capturingControl[pointerId]) {
  1172. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1173. return;
  1174. }
  1175. this._cursorChanged = false;
  1176. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1177. this._changeCursor("");
  1178. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1179. if (this._lastControlOver[pointerId]) {
  1180. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1181. delete this._lastControlOver[pointerId];
  1182. }
  1183. }
  1184. }
  1185. if (!this._cursorChanged) {
  1186. this._changeCursor("");
  1187. }
  1188. this._manageFocus();
  1189. };
  1190. /** @hidden */
  1191. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1192. for (var pointerId in list) {
  1193. if (!list.hasOwnProperty(pointerId)) {
  1194. continue;
  1195. }
  1196. var lastControlOver = list[pointerId];
  1197. if (lastControlOver === control) {
  1198. delete list[pointerId];
  1199. }
  1200. }
  1201. };
  1202. /** @hidden */
  1203. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1204. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1205. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1206. };
  1207. /** Attach to all scene events required to support pointer events */
  1208. AdvancedDynamicTexture.prototype.attach = function () {
  1209. var _this = this;
  1210. var scene = this.getScene();
  1211. if (!scene) {
  1212. return;
  1213. }
  1214. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1215. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1216. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1217. return;
  1218. }
  1219. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1220. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1221. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1222. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1223. return;
  1224. }
  1225. if (!scene) {
  1226. return;
  1227. }
  1228. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1229. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1230. }
  1231. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1232. var engine = scene.getEngine();
  1233. if (!camera) {
  1234. tempViewport.x = 0;
  1235. tempViewport.y = 0;
  1236. tempViewport.width = engine.getRenderWidth();
  1237. tempViewport.height = engine.getRenderHeight();
  1238. }
  1239. else {
  1240. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1241. }
  1242. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1243. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1244. _this._shouldBlockPointer = false;
  1245. // Do picking modifies _shouldBlockPointer
  1246. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1247. _this._doPicking(x, y, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1248. // Avoid overwriting a true skipOnPointerObservable to false
  1249. if (_this._shouldBlockPointer) {
  1250. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1251. }
  1252. });
  1253. this._attachToOnPointerOut(scene);
  1254. };
  1255. /**
  1256. * Register the clipboard Events onto the canvas
  1257. */
  1258. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1259. self.addEventListener("copy", this.onClipboardCopy, false);
  1260. self.addEventListener("cut", this.onClipboardCut, false);
  1261. self.addEventListener("paste", this.onClipboardPaste, false);
  1262. };
  1263. /**
  1264. * Unregister the clipboard Events from the canvas
  1265. */
  1266. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1267. self.removeEventListener("copy", this.onClipboardCopy);
  1268. self.removeEventListener("cut", this.onClipboardCut);
  1269. self.removeEventListener("paste", this.onClipboardPaste);
  1270. };
  1271. /**
  1272. * Connect the texture to a hosting mesh to enable interactions
  1273. * @param mesh defines the mesh to attach to
  1274. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1275. */
  1276. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1277. var _this = this;
  1278. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1279. var scene = this.getScene();
  1280. if (!scene) {
  1281. return;
  1282. }
  1283. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1284. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1285. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1286. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1287. return;
  1288. }
  1289. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1290. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1291. var uv = pi.pickInfo.getTextureCoordinates();
  1292. if (uv) {
  1293. var size = _this.getSize();
  1294. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1295. }
  1296. }
  1297. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1298. if (_this._lastControlDown[pointerId]) {
  1299. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1300. }
  1301. delete _this._lastControlDown[pointerId];
  1302. if (_this.focusedControl) {
  1303. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1304. var canMoveFocus = true;
  1305. if (friendlyControls) {
  1306. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1307. var control = friendlyControls_1[_i];
  1308. // Same host, no need to keep the focus
  1309. if (_this === control._host) {
  1310. continue;
  1311. }
  1312. // Different hosts
  1313. var otherHost = control._host;
  1314. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1315. canMoveFocus = false;
  1316. break;
  1317. }
  1318. }
  1319. }
  1320. if (canMoveFocus) {
  1321. _this.focusedControl = null;
  1322. }
  1323. }
  1324. }
  1325. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1326. if (_this._lastControlOver[pointerId]) {
  1327. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1328. }
  1329. delete _this._lastControlOver[pointerId];
  1330. }
  1331. });
  1332. mesh.enablePointerMoveEvents = supportPointerMove;
  1333. this._attachToOnPointerOut(scene);
  1334. };
  1335. /**
  1336. * Move the focus to a specific control
  1337. * @param control defines the control which will receive the focus
  1338. */
  1339. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1340. this.focusedControl = control;
  1341. this._lastPickedControl = control;
  1342. this._blockNextFocusCheck = true;
  1343. };
  1344. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1345. if (this._blockNextFocusCheck) {
  1346. this._blockNextFocusCheck = false;
  1347. this._lastPickedControl = this._focusedControl;
  1348. return;
  1349. }
  1350. // Focus management
  1351. if (this._focusedControl) {
  1352. if (this._focusedControl !== this._lastPickedControl) {
  1353. if (this._lastPickedControl.isFocusInvisible) {
  1354. return;
  1355. }
  1356. this.focusedControl = null;
  1357. }
  1358. }
  1359. };
  1360. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1361. var _this = this;
  1362. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1363. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1364. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1365. }
  1366. delete _this._lastControlOver[pointerEvent.pointerId];
  1367. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1368. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1369. delete _this._lastControlDown[pointerEvent.pointerId];
  1370. }
  1371. });
  1372. };
  1373. // Statics
  1374. /**
  1375. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1376. * @param mesh defines the mesh which will receive the texture
  1377. * @param width defines the texture width (1024 by default)
  1378. * @param height defines the texture height (1024 by default)
  1379. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1380. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1381. * @returns a new AdvancedDynamicTexture
  1382. */
  1383. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1384. if (width === void 0) { width = 1024; }
  1385. if (height === void 0) { height = 1024; }
  1386. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1387. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1388. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1389. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1390. material.backFaceCulling = false;
  1391. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1392. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1393. if (onlyAlphaTesting) {
  1394. material.diffuseTexture = result;
  1395. material.emissiveTexture = result;
  1396. result.hasAlpha = true;
  1397. }
  1398. else {
  1399. material.emissiveTexture = result;
  1400. material.opacityTexture = result;
  1401. }
  1402. mesh.material = material;
  1403. result.attachToMesh(mesh, supportPointerMove);
  1404. return result;
  1405. };
  1406. /**
  1407. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1408. * In this mode the texture will rely on a layer for its rendering.
  1409. * This allows it to be treated like any other layer.
  1410. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1411. * LayerMask is set through advancedTexture.layer.layerMask
  1412. * @param name defines name for the texture
  1413. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1414. * @param scene defines the hsoting scene
  1415. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1416. * @returns a new AdvancedDynamicTexture
  1417. */
  1418. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1419. if (foreground === void 0) { foreground = true; }
  1420. if (scene === void 0) { scene = null; }
  1421. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1422. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1423. // Display
  1424. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1425. layer.texture = result;
  1426. result._layerToDispose = layer;
  1427. result._isFullscreen = true;
  1428. // Attach
  1429. result.attach();
  1430. return result;
  1431. };
  1432. return AdvancedDynamicTexture;
  1433. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1434. /***/ }),
  1435. /***/ "./2D/controls/button.ts":
  1436. /*!*******************************!*\
  1437. !*** ./2D/controls/button.ts ***!
  1438. \*******************************/
  1439. /*! exports provided: Button */
  1440. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1441. "use strict";
  1442. __webpack_require__.r(__webpack_exports__);
  1443. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1444. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1445. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1446. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1447. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1448. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1449. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1450. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1451. /**
  1452. * Class used to create 2D buttons
  1453. */
  1454. var Button = /** @class */ (function (_super) {
  1455. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1456. /**
  1457. * Creates a new Button
  1458. * @param name defines the name of the button
  1459. */
  1460. function Button(name) {
  1461. var _this = _super.call(this, name) || this;
  1462. _this.name = name;
  1463. /**
  1464. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1465. */
  1466. _this.delegatePickingToChildren = false;
  1467. _this.thickness = 1;
  1468. _this.isPointerBlocker = true;
  1469. var alphaStore = null;
  1470. _this.pointerEnterAnimation = function () {
  1471. alphaStore = _this.alpha;
  1472. _this.alpha -= 0.1;
  1473. };
  1474. _this.pointerOutAnimation = function () {
  1475. if (alphaStore !== null) {
  1476. _this.alpha = alphaStore;
  1477. }
  1478. };
  1479. _this.pointerDownAnimation = function () {
  1480. _this.scaleX -= 0.05;
  1481. _this.scaleY -= 0.05;
  1482. };
  1483. _this.pointerUpAnimation = function () {
  1484. _this.scaleX += 0.05;
  1485. _this.scaleY += 0.05;
  1486. };
  1487. return _this;
  1488. }
  1489. Object.defineProperty(Button.prototype, "image", {
  1490. /**
  1491. * Returns the image part of the button (if any)
  1492. */
  1493. get: function () {
  1494. return this._image;
  1495. },
  1496. enumerable: false,
  1497. configurable: true
  1498. });
  1499. Object.defineProperty(Button.prototype, "textBlock", {
  1500. /**
  1501. * Returns the image part of the button (if any)
  1502. */
  1503. get: function () {
  1504. return this._textBlock;
  1505. },
  1506. enumerable: false,
  1507. configurable: true
  1508. });
  1509. Button.prototype._getTypeName = function () {
  1510. return "Button";
  1511. };
  1512. // While being a container, the button behaves like a control.
  1513. /** @hidden */
  1514. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1515. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1516. return false;
  1517. }
  1518. if (!_super.prototype.contains.call(this, x, y)) {
  1519. return false;
  1520. }
  1521. if (this.delegatePickingToChildren) {
  1522. var contains = false;
  1523. for (var index = this._children.length - 1; index >= 0; index--) {
  1524. var child = this._children[index];
  1525. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1526. contains = true;
  1527. break;
  1528. }
  1529. }
  1530. if (!contains) {
  1531. return false;
  1532. }
  1533. }
  1534. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  1535. return true;
  1536. };
  1537. /** @hidden */
  1538. Button.prototype._onPointerEnter = function (target) {
  1539. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1540. return false;
  1541. }
  1542. if (this.pointerEnterAnimation) {
  1543. this.pointerEnterAnimation();
  1544. }
  1545. return true;
  1546. };
  1547. /** @hidden */
  1548. Button.prototype._onPointerOut = function (target, force) {
  1549. if (force === void 0) { force = false; }
  1550. if (this.pointerOutAnimation) {
  1551. this.pointerOutAnimation();
  1552. }
  1553. _super.prototype._onPointerOut.call(this, target, force);
  1554. };
  1555. /** @hidden */
  1556. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1557. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1558. return false;
  1559. }
  1560. if (this.pointerDownAnimation) {
  1561. this.pointerDownAnimation();
  1562. }
  1563. return true;
  1564. };
  1565. /** @hidden */
  1566. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1567. if (this.pointerUpAnimation) {
  1568. this.pointerUpAnimation();
  1569. }
  1570. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1571. };
  1572. // Statics
  1573. /**
  1574. * Creates a new button made with an image and a text
  1575. * @param name defines the name of the button
  1576. * @param text defines the text of the button
  1577. * @param imageUrl defines the url of the image
  1578. * @returns a new Button
  1579. */
  1580. Button.CreateImageButton = function (name, text, imageUrl) {
  1581. var result = new Button(name);
  1582. // Adding text
  1583. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1584. textBlock.textWrapping = true;
  1585. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1586. textBlock.paddingLeft = "20%";
  1587. result.addControl(textBlock);
  1588. // Adding image
  1589. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1590. iconImage.width = "20%";
  1591. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1592. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1593. result.addControl(iconImage);
  1594. // Store
  1595. result._image = iconImage;
  1596. result._textBlock = textBlock;
  1597. return result;
  1598. };
  1599. /**
  1600. * Creates a new button made with an image
  1601. * @param name defines the name of the button
  1602. * @param imageUrl defines the url of the image
  1603. * @returns a new Button
  1604. */
  1605. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1606. var result = new Button(name);
  1607. // Adding image
  1608. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1609. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1610. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1611. result.addControl(iconImage);
  1612. // Store
  1613. result._image = iconImage;
  1614. return result;
  1615. };
  1616. /**
  1617. * Creates a new button made with a text
  1618. * @param name defines the name of the button
  1619. * @param text defines the text of the button
  1620. * @returns a new Button
  1621. */
  1622. Button.CreateSimpleButton = function (name, text) {
  1623. var result = new Button(name);
  1624. // Adding text
  1625. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1626. textBlock.textWrapping = true;
  1627. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1628. result.addControl(textBlock);
  1629. // Store
  1630. result._textBlock = textBlock;
  1631. return result;
  1632. };
  1633. /**
  1634. * Creates a new button made with an image and a centered text
  1635. * @param name defines the name of the button
  1636. * @param text defines the text of the button
  1637. * @param imageUrl defines the url of the image
  1638. * @returns a new Button
  1639. */
  1640. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1641. var result = new Button(name);
  1642. // Adding image
  1643. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1644. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1645. result.addControl(iconImage);
  1646. // Adding text
  1647. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1648. textBlock.textWrapping = true;
  1649. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1650. result.addControl(textBlock);
  1651. // Store
  1652. result._image = iconImage;
  1653. result._textBlock = textBlock;
  1654. return result;
  1655. };
  1656. return Button;
  1657. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1658. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1659. /***/ }),
  1660. /***/ "./2D/controls/checkbox.ts":
  1661. /*!*********************************!*\
  1662. !*** ./2D/controls/checkbox.ts ***!
  1663. \*********************************/
  1664. /*! exports provided: Checkbox */
  1665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1666. "use strict";
  1667. __webpack_require__.r(__webpack_exports__);
  1668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1670. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1671. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1672. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1673. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1674. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1675. /**
  1676. * Class used to represent a 2D checkbox
  1677. */
  1678. var Checkbox = /** @class */ (function (_super) {
  1679. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1680. /**
  1681. * Creates a new CheckBox
  1682. * @param name defines the control name
  1683. */
  1684. function Checkbox(name) {
  1685. var _this = _super.call(this, name) || this;
  1686. _this.name = name;
  1687. _this._isChecked = false;
  1688. _this._background = "black";
  1689. _this._checkSizeRatio = 0.8;
  1690. _this._thickness = 1;
  1691. /**
  1692. * Observable raised when isChecked property changes
  1693. */
  1694. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1695. _this.isPointerBlocker = true;
  1696. return _this;
  1697. }
  1698. Object.defineProperty(Checkbox.prototype, "thickness", {
  1699. /** Gets or sets border thickness */
  1700. get: function () {
  1701. return this._thickness;
  1702. },
  1703. set: function (value) {
  1704. if (this._thickness === value) {
  1705. return;
  1706. }
  1707. this._thickness = value;
  1708. this._markAsDirty();
  1709. },
  1710. enumerable: false,
  1711. configurable: true
  1712. });
  1713. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1714. /** Gets or sets a value indicating the ratio between overall size and check size */
  1715. get: function () {
  1716. return this._checkSizeRatio;
  1717. },
  1718. set: function (value) {
  1719. value = Math.max(Math.min(1, value), 0);
  1720. if (this._checkSizeRatio === value) {
  1721. return;
  1722. }
  1723. this._checkSizeRatio = value;
  1724. this._markAsDirty();
  1725. },
  1726. enumerable: false,
  1727. configurable: true
  1728. });
  1729. Object.defineProperty(Checkbox.prototype, "background", {
  1730. /** Gets or sets background color */
  1731. get: function () {
  1732. return this._background;
  1733. },
  1734. set: function (value) {
  1735. if (this._background === value) {
  1736. return;
  1737. }
  1738. this._background = value;
  1739. this._markAsDirty();
  1740. },
  1741. enumerable: false,
  1742. configurable: true
  1743. });
  1744. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1745. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1746. get: function () {
  1747. return this._isChecked;
  1748. },
  1749. set: function (value) {
  1750. if (this._isChecked === value) {
  1751. return;
  1752. }
  1753. this._isChecked = value;
  1754. this._markAsDirty();
  1755. this.onIsCheckedChangedObservable.notifyObservers(value);
  1756. },
  1757. enumerable: false,
  1758. configurable: true
  1759. });
  1760. Checkbox.prototype._getTypeName = function () {
  1761. return "Checkbox";
  1762. };
  1763. /** @hidden */
  1764. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1765. context.save();
  1766. this._applyStates(context);
  1767. var actualWidth = this._currentMeasure.width - this._thickness;
  1768. var actualHeight = this._currentMeasure.height - this._thickness;
  1769. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1770. context.shadowColor = this.shadowColor;
  1771. context.shadowBlur = this.shadowBlur;
  1772. context.shadowOffsetX = this.shadowOffsetX;
  1773. context.shadowOffsetY = this.shadowOffsetY;
  1774. }
  1775. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1776. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1777. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1778. context.shadowBlur = 0;
  1779. context.shadowOffsetX = 0;
  1780. context.shadowOffsetY = 0;
  1781. }
  1782. if (this._isChecked) {
  1783. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1784. var offsetWidth = actualWidth * this._checkSizeRatio;
  1785. var offseHeight = actualHeight * this._checkSizeRatio;
  1786. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1787. }
  1788. context.strokeStyle = this.color;
  1789. context.lineWidth = this._thickness;
  1790. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1791. context.restore();
  1792. };
  1793. // Events
  1794. /** @hidden */
  1795. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1796. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1797. return false;
  1798. }
  1799. this.isChecked = !this.isChecked;
  1800. return true;
  1801. };
  1802. /**
  1803. * Utility function to easily create a checkbox with a header
  1804. * @param title defines the label to use for the header
  1805. * @param onValueChanged defines the callback to call when value changes
  1806. * @returns a StackPanel containing the checkbox and a textBlock
  1807. */
  1808. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1809. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1810. panel.isVertical = false;
  1811. panel.height = "30px";
  1812. var checkbox = new Checkbox();
  1813. checkbox.width = "20px";
  1814. checkbox.height = "20px";
  1815. checkbox.isChecked = true;
  1816. checkbox.color = "green";
  1817. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1818. panel.addControl(checkbox);
  1819. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1820. header.text = title;
  1821. header.width = "180px";
  1822. header.paddingLeft = "5px";
  1823. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1824. header.color = "white";
  1825. panel.addControl(header);
  1826. return panel;
  1827. };
  1828. return Checkbox;
  1829. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1830. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1831. /***/ }),
  1832. /***/ "./2D/controls/colorpicker.ts":
  1833. /*!************************************!*\
  1834. !*** ./2D/controls/colorpicker.ts ***!
  1835. \************************************/
  1836. /*! exports provided: ColorPicker */
  1837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1838. "use strict";
  1839. __webpack_require__.r(__webpack_exports__);
  1840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1841. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1842. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1843. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1844. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1845. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1846. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1847. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1848. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1849. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1850. /** Class used to create color pickers */
  1851. var ColorPicker = /** @class */ (function (_super) {
  1852. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1853. /**
  1854. * Creates a new ColorPicker
  1855. * @param name defines the control name
  1856. */
  1857. function ColorPicker(name) {
  1858. var _this = _super.call(this, name) || this;
  1859. _this.name = name;
  1860. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1861. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1862. _this._pointerStartedOnSquare = false;
  1863. _this._pointerStartedOnWheel = false;
  1864. _this._squareLeft = 0;
  1865. _this._squareTop = 0;
  1866. _this._squareSize = 0;
  1867. _this._h = 360;
  1868. _this._s = 1;
  1869. _this._v = 1;
  1870. _this._lastPointerDownID = -1;
  1871. /**
  1872. * Observable raised when the value changes
  1873. */
  1874. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1875. // Events
  1876. _this._pointerIsDown = false;
  1877. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1878. _this.size = "200px";
  1879. _this.isPointerBlocker = true;
  1880. return _this;
  1881. }
  1882. Object.defineProperty(ColorPicker.prototype, "value", {
  1883. /** Gets or sets the color of the color picker */
  1884. get: function () {
  1885. return this._value;
  1886. },
  1887. set: function (value) {
  1888. if (this._value.equals(value)) {
  1889. return;
  1890. }
  1891. this._value.copyFrom(value);
  1892. this._value.toHSVToRef(this._tmpColor);
  1893. this._h = this._tmpColor.r;
  1894. this._s = Math.max(this._tmpColor.g, 0.00001);
  1895. this._v = Math.max(this._tmpColor.b, 0.00001);
  1896. this._markAsDirty();
  1897. if (this._value.r <= ColorPicker._Epsilon) {
  1898. this._value.r = 0;
  1899. }
  1900. if (this._value.g <= ColorPicker._Epsilon) {
  1901. this._value.g = 0;
  1902. }
  1903. if (this._value.b <= ColorPicker._Epsilon) {
  1904. this._value.b = 0;
  1905. }
  1906. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1907. this._value.r = 1.0;
  1908. }
  1909. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1910. this._value.g = 1.0;
  1911. }
  1912. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1913. this._value.b = 1.0;
  1914. }
  1915. this.onValueChangedObservable.notifyObservers(this._value);
  1916. },
  1917. enumerable: false,
  1918. configurable: true
  1919. });
  1920. Object.defineProperty(ColorPicker.prototype, "width", {
  1921. /**
  1922. * Gets or sets control width
  1923. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1924. */
  1925. get: function () {
  1926. return this._width.toString(this._host);
  1927. },
  1928. set: function (value) {
  1929. if (this._width.toString(this._host) === value) {
  1930. return;
  1931. }
  1932. if (this._width.fromString(value)) {
  1933. this._height.fromString(value);
  1934. this._markAsDirty();
  1935. }
  1936. },
  1937. enumerable: false,
  1938. configurable: true
  1939. });
  1940. Object.defineProperty(ColorPicker.prototype, "height", {
  1941. /**
  1942. * Gets or sets control height
  1943. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1944. */
  1945. get: function () {
  1946. return this._height.toString(this._host);
  1947. },
  1948. /** Gets or sets control height */
  1949. set: function (value) {
  1950. if (this._height.toString(this._host) === value) {
  1951. return;
  1952. }
  1953. if (this._height.fromString(value)) {
  1954. this._width.fromString(value);
  1955. this._markAsDirty();
  1956. }
  1957. },
  1958. enumerable: false,
  1959. configurable: true
  1960. });
  1961. Object.defineProperty(ColorPicker.prototype, "size", {
  1962. /** Gets or sets control size */
  1963. get: function () {
  1964. return this.width;
  1965. },
  1966. set: function (value) {
  1967. this.width = value;
  1968. },
  1969. enumerable: false,
  1970. configurable: true
  1971. });
  1972. ColorPicker.prototype._getTypeName = function () {
  1973. return "ColorPicker";
  1974. };
  1975. /** @hidden */
  1976. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1977. if (parentMeasure.width < parentMeasure.height) {
  1978. this._currentMeasure.height = parentMeasure.width;
  1979. }
  1980. else {
  1981. this._currentMeasure.width = parentMeasure.height;
  1982. }
  1983. };
  1984. ColorPicker.prototype._updateSquareProps = function () {
  1985. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1986. var wheelThickness = radius * .2;
  1987. var innerDiameter = (radius - wheelThickness) * 2;
  1988. var squareSize = innerDiameter / (Math.sqrt(2));
  1989. var offset = radius - squareSize * .5;
  1990. this._squareLeft = this._currentMeasure.left + offset;
  1991. this._squareTop = this._currentMeasure.top + offset;
  1992. this._squareSize = squareSize;
  1993. };
  1994. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1995. var lgh = context.createLinearGradient(left, top, width + left, top);
  1996. lgh.addColorStop(0, '#fff');
  1997. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1998. context.fillStyle = lgh;
  1999. context.fillRect(left, top, width, height);
  2000. var lgv = context.createLinearGradient(left, top, left, height + top);
  2001. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  2002. lgv.addColorStop(1, '#000');
  2003. context.fillStyle = lgv;
  2004. context.fillRect(left, top, width, height);
  2005. };
  2006. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  2007. context.beginPath();
  2008. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  2009. context.lineWidth = 3;
  2010. context.strokeStyle = '#333333';
  2011. context.stroke();
  2012. context.beginPath();
  2013. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  2014. context.lineWidth = 3;
  2015. context.strokeStyle = '#ffffff';
  2016. context.stroke();
  2017. };
  2018. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2019. var canvas = document.createElement("canvas");
  2020. canvas.width = radius * 2;
  2021. canvas.height = radius * 2;
  2022. var context = canvas.getContext("2d");
  2023. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2024. var data = image.data;
  2025. var color = this._tmpColor;
  2026. var maxDistSq = radius * radius;
  2027. var innerRadius = radius - thickness;
  2028. var minDistSq = innerRadius * innerRadius;
  2029. for (var x = -radius; x < radius; x++) {
  2030. for (var y = -radius; y < radius; y++) {
  2031. var distSq = x * x + y * y;
  2032. if (distSq > maxDistSq || distSq < minDistSq) {
  2033. continue;
  2034. }
  2035. var dist = Math.sqrt(distSq);
  2036. var ang = Math.atan2(y, x);
  2037. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2038. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2039. data[index] = color.r * 255;
  2040. data[index + 1] = color.g * 255;
  2041. data[index + 2] = color.b * 255;
  2042. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2043. //apply less alpha to bigger color pickers
  2044. var alphaAmount = .2;
  2045. var maxAlpha = .2;
  2046. var minAlpha = .04;
  2047. var lowerRadius = 50;
  2048. var upperRadius = 150;
  2049. if (radius < lowerRadius) {
  2050. alphaAmount = maxAlpha;
  2051. }
  2052. else if (radius > upperRadius) {
  2053. alphaAmount = minAlpha;
  2054. }
  2055. else {
  2056. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2057. }
  2058. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2059. if (alphaRatio < alphaAmount) {
  2060. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2061. }
  2062. else if (alphaRatio > 1 - alphaAmount) {
  2063. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2064. }
  2065. else {
  2066. data[index + 3] = 255;
  2067. }
  2068. }
  2069. }
  2070. context.putImageData(image, 0, 0);
  2071. return canvas;
  2072. };
  2073. /** @hidden */
  2074. ColorPicker.prototype._draw = function (context) {
  2075. context.save();
  2076. this._applyStates(context);
  2077. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2078. var wheelThickness = radius * .2;
  2079. var left = this._currentMeasure.left;
  2080. var top = this._currentMeasure.top;
  2081. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2082. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2083. }
  2084. this._updateSquareProps();
  2085. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2086. context.shadowColor = this.shadowColor;
  2087. context.shadowBlur = this.shadowBlur;
  2088. context.shadowOffsetX = this.shadowOffsetX;
  2089. context.shadowOffsetY = this.shadowOffsetY;
  2090. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2091. }
  2092. context.drawImage(this._colorWheelCanvas, left, top);
  2093. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2094. context.shadowBlur = 0;
  2095. context.shadowOffsetX = 0;
  2096. context.shadowOffsetY = 0;
  2097. }
  2098. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2099. var cx = this._squareLeft + this._squareSize * this._s;
  2100. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2101. this._drawCircle(cx, cy, radius * .04, context);
  2102. var dist = radius - wheelThickness * .5;
  2103. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2104. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2105. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2106. context.restore();
  2107. };
  2108. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2109. if (this._pointerStartedOnWheel) {
  2110. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2111. var centerX = radius + this._currentMeasure.left;
  2112. var centerY = radius + this._currentMeasure.top;
  2113. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2114. }
  2115. else if (this._pointerStartedOnSquare) {
  2116. this._updateSquareProps();
  2117. this._s = (x - this._squareLeft) / this._squareSize;
  2118. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2119. this._s = Math.min(this._s, 1);
  2120. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2121. this._v = Math.min(this._v, 1);
  2122. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2123. }
  2124. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2125. this.value = this._tmpColor;
  2126. };
  2127. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2128. this._updateSquareProps();
  2129. var left = this._squareLeft;
  2130. var top = this._squareTop;
  2131. var size = this._squareSize;
  2132. if (x >= left && x <= left + size &&
  2133. y >= top && y <= top + size) {
  2134. return true;
  2135. }
  2136. return false;
  2137. };
  2138. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2139. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2140. var centerX = radius + this._currentMeasure.left;
  2141. var centerY = radius + this._currentMeasure.top;
  2142. var wheelThickness = radius * .2;
  2143. var innerRadius = radius - wheelThickness;
  2144. var radiusSq = radius * radius;
  2145. var innerRadiusSq = innerRadius * innerRadius;
  2146. var dx = x - centerX;
  2147. var dy = y - centerY;
  2148. var distSq = dx * dx + dy * dy;
  2149. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2150. return true;
  2151. }
  2152. return false;
  2153. };
  2154. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2155. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2156. return false;
  2157. }
  2158. this._pointerIsDown = true;
  2159. this._pointerStartedOnSquare = false;
  2160. this._pointerStartedOnWheel = false;
  2161. // Invert transform
  2162. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2163. var x = this._transformedPosition.x;
  2164. var y = this._transformedPosition.y;
  2165. if (this._isPointOnSquare(x, y)) {
  2166. this._pointerStartedOnSquare = true;
  2167. }
  2168. else if (this._isPointOnWheel(x, y)) {
  2169. this._pointerStartedOnWheel = true;
  2170. }
  2171. this._updateValueFromPointer(x, y);
  2172. this._host._capturingControl[pointerId] = this;
  2173. this._lastPointerDownID = pointerId;
  2174. return true;
  2175. };
  2176. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2177. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2178. if (pointerId != this._lastPointerDownID) {
  2179. return;
  2180. }
  2181. // Invert transform
  2182. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2183. var x = this._transformedPosition.x;
  2184. var y = this._transformedPosition.y;
  2185. if (this._pointerIsDown) {
  2186. this._updateValueFromPointer(x, y);
  2187. }
  2188. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2189. };
  2190. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2191. this._pointerIsDown = false;
  2192. delete this._host._capturingControl[pointerId];
  2193. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2194. };
  2195. /**
  2196. * This function expands the color picker by creating a color picker dialog with manual
  2197. * color value input and the ability to save colors into an array to be used later in
  2198. * subsequent launches of the dialogue.
  2199. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2200. * @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.
  2201. * @returns picked color as a hex string and the saved colors array as hex strings.
  2202. */
  2203. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2204. return new Promise(function (resolve, reject) {
  2205. // Default options
  2206. options.pickerWidth = options.pickerWidth || "640px";
  2207. options.pickerHeight = options.pickerHeight || "400px";
  2208. options.headerHeight = options.headerHeight || "35px";
  2209. options.lastColor = options.lastColor || "#000000";
  2210. options.swatchLimit = options.swatchLimit || 20;
  2211. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2212. // Window size settings
  2213. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2214. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2215. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2216. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2217. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2218. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2219. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2220. // Button Colors
  2221. var buttonColor = "#c0c0c0";
  2222. var buttonBackgroundColor = "#535353";
  2223. var buttonBackgroundHoverColor = "#414141";
  2224. var buttonBackgroundClickColor = "515151";
  2225. var buttonDisabledColor = "#555555";
  2226. var buttonDisabledBackgroundColor = "#454545";
  2227. var currentSwatchesOutlineColor = "#404040";
  2228. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2229. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2230. var iconColorDark = "#aaaaaa";
  2231. var iconColorLight = "#ffffff";
  2232. var closeIconColor;
  2233. // Button settings
  2234. var buttonFontSize;
  2235. var butEdit;
  2236. var buttonWidth;
  2237. var buttonHeight;
  2238. // Input Text Colors
  2239. var inputFieldLabels = ["R", "G", "B"];
  2240. var inputTextBackgroundColor = "#454545";
  2241. var inputTextColor = "#f0f0f0";
  2242. // This is the current color as set by either the picker or by entering a value
  2243. var currentColor;
  2244. // This int is used for naming swatches and serves as the index for calling them from the list
  2245. var swatchNumber;
  2246. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2247. var swatchDrawer;
  2248. var editSwatchMode = false;
  2249. // Color InputText fields that will be updated upon value change
  2250. var picker;
  2251. var rValInt;
  2252. var gValInt;
  2253. var bValInt;
  2254. var rValDec;
  2255. var gValDec;
  2256. var bValDec;
  2257. var hexVal;
  2258. var newSwatch;
  2259. var lastVal;
  2260. var activeField;
  2261. /**
  2262. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2263. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2264. * are will receive no update. This is to prevent the input from the user being overwritten.
  2265. */
  2266. function updateValues(value, inputField) {
  2267. activeField = inputField;
  2268. var pickedColor = value.toHexString();
  2269. newSwatch.background = pickedColor;
  2270. if (rValInt.name != activeField) {
  2271. rValInt.text = Math.floor(value.r * 255).toString();
  2272. }
  2273. if (gValInt.name != activeField) {
  2274. gValInt.text = Math.floor(value.g * 255).toString();
  2275. }
  2276. if (bValInt.name != activeField) {
  2277. bValInt.text = Math.floor(value.b * 255).toString();
  2278. }
  2279. if (rValDec.name != activeField) {
  2280. rValDec.text = value.r.toString();
  2281. }
  2282. if (gValDec.name != activeField) {
  2283. gValDec.text = value.g.toString();
  2284. }
  2285. if (bValDec.name != activeField) {
  2286. bValDec.text = value.b.toString();
  2287. }
  2288. if (hexVal.name != activeField) {
  2289. var minusPound = pickedColor.split("#");
  2290. hexVal.text = minusPound[1];
  2291. }
  2292. if (picker.name != activeField) {
  2293. picker.value = value;
  2294. }
  2295. }
  2296. // 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.
  2297. function updateInt(field, channel) {
  2298. var newValue = field.text;
  2299. var checkVal = /[^0-9]/g.test(newValue);
  2300. if (checkVal) {
  2301. field.text = lastVal;
  2302. return;
  2303. }
  2304. else {
  2305. if (newValue != "") {
  2306. if (Math.floor(parseInt(newValue)) < 0) {
  2307. newValue = "0";
  2308. }
  2309. else if (Math.floor(parseInt(newValue)) > 255) {
  2310. newValue = "255";
  2311. }
  2312. else if (isNaN(parseInt(newValue))) {
  2313. newValue = "0";
  2314. }
  2315. }
  2316. if (activeField == field.name) {
  2317. lastVal = newValue;
  2318. }
  2319. }
  2320. if (newValue != "") {
  2321. newValue = parseInt(newValue).toString();
  2322. field.text = newValue;
  2323. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2324. if (activeField == field.name) {
  2325. if (channel == "r") {
  2326. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2327. }
  2328. else if (channel == "g") {
  2329. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2330. }
  2331. else {
  2332. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2333. }
  2334. }
  2335. }
  2336. }
  2337. // 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.
  2338. function updateFloat(field, channel) {
  2339. var newValue = field.text;
  2340. var checkVal = /[^0-9\.]/g.test(newValue);
  2341. if (checkVal) {
  2342. field.text = lastVal;
  2343. return;
  2344. }
  2345. else {
  2346. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2347. if (parseFloat(newValue) < 0.0) {
  2348. newValue = "0.0";
  2349. }
  2350. else if (parseFloat(newValue) > 1.0) {
  2351. newValue = "1.0";
  2352. }
  2353. else if (isNaN(parseFloat(newValue))) {
  2354. newValue = "0.0";
  2355. }
  2356. }
  2357. if (activeField == field.name) {
  2358. lastVal = newValue;
  2359. }
  2360. }
  2361. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2362. newValue = parseFloat(newValue).toString();
  2363. field.text = newValue;
  2364. }
  2365. else {
  2366. newValue = "0.0";
  2367. }
  2368. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2369. if (activeField == field.name) {
  2370. if (channel == "r") {
  2371. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2372. }
  2373. else if (channel == "g") {
  2374. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2375. }
  2376. else {
  2377. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2378. }
  2379. }
  2380. }
  2381. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2382. function deleteSwatch(index) {
  2383. if (options.savedColors) {
  2384. options.savedColors.splice(index, 1);
  2385. }
  2386. if (options.savedColors && options.savedColors.length == 0) {
  2387. setEditButtonVisibility(false);
  2388. editSwatchMode = false;
  2389. }
  2390. }
  2391. // Creates and styles an individual swatch when updateSwatches is called.
  2392. function createSwatch() {
  2393. if (options.savedColors && options.savedColors[swatchNumber]) {
  2394. if (editSwatchMode) {
  2395. var icon = "b";
  2396. }
  2397. else {
  2398. var icon = "";
  2399. }
  2400. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2401. swatch.fontFamily = "BabylonJSglyphs";
  2402. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2403. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2404. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2405. if (swatchLuminence > luminanceLimit) {
  2406. swatch.color = iconColorDark;
  2407. }
  2408. else {
  2409. swatch.color = iconColorLight;
  2410. }
  2411. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2412. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2413. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2414. swatch.background = options.savedColors[swatchNumber];
  2415. swatch.thickness = 2;
  2416. var metadata_1 = swatchNumber;
  2417. swatch.pointerDownAnimation = function () {
  2418. swatch.thickness = 4;
  2419. };
  2420. swatch.pointerUpAnimation = function () {
  2421. swatch.thickness = 3;
  2422. };
  2423. swatch.pointerEnterAnimation = function () {
  2424. swatch.thickness = 3;
  2425. };
  2426. swatch.pointerOutAnimation = function () {
  2427. swatch.thickness = 2;
  2428. };
  2429. swatch.onPointerClickObservable.add(function () {
  2430. if (!editSwatchMode) {
  2431. if (options.savedColors) {
  2432. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2433. }
  2434. }
  2435. else {
  2436. deleteSwatch(metadata_1);
  2437. updateSwatches("", butSave);
  2438. }
  2439. });
  2440. return swatch;
  2441. }
  2442. else {
  2443. return null;
  2444. }
  2445. }
  2446. // Mode switch to render button text and close symbols on swatch controls
  2447. function editSwatches(mode) {
  2448. if (mode !== undefined) {
  2449. editSwatchMode = mode;
  2450. }
  2451. if (editSwatchMode) {
  2452. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2453. var thisButton = swatchDrawer.children[i];
  2454. thisButton.textBlock.text = "b";
  2455. }
  2456. if (butEdit !== undefined) {
  2457. butEdit.textBlock.text = "Done";
  2458. }
  2459. }
  2460. else {
  2461. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2462. var thisButton = swatchDrawer.children[i];
  2463. thisButton.textBlock.text = "";
  2464. }
  2465. if (butEdit !== undefined) {
  2466. butEdit.textBlock.text = "Edit";
  2467. }
  2468. }
  2469. }
  2470. /**
  2471. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2472. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2473. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2474. * saved colors there are and how many can be stored per row.
  2475. */
  2476. function updateSwatches(color, button) {
  2477. if (options.savedColors) {
  2478. if (color != "") {
  2479. options.savedColors.push(color);
  2480. }
  2481. swatchNumber = 0;
  2482. swatchDrawer.clearControls();
  2483. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2484. if (rowCount == 0) {
  2485. var gutterCount = 0;
  2486. }
  2487. else {
  2488. var gutterCount = rowCount + 1;
  2489. }
  2490. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2491. var currentRows = swatchDrawer.rowCount;
  2492. for (var i = 0; i < currentRows; i++) {
  2493. swatchDrawer.removeRowDefinition(0);
  2494. }
  2495. for (var i = 0; i < rowCount + gutterCount; i++) {
  2496. if (i % 2) {
  2497. swatchDrawer.addRowDefinition(swatchSize, true);
  2498. }
  2499. else {
  2500. swatchDrawer.addRowDefinition(gutterSize, true);
  2501. }
  2502. }
  2503. }
  2504. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2505. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2506. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2507. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2508. var totalButtonsThisRow = options.numSwatchesPerLine;
  2509. }
  2510. else {
  2511. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2512. }
  2513. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2514. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2515. if (x > options.numSwatchesPerLine) {
  2516. continue;
  2517. }
  2518. var swatch = createSwatch();
  2519. if (swatch != null) {
  2520. swatchDrawer.addControl(swatch, y, w);
  2521. w += 2;
  2522. swatchNumber++;
  2523. }
  2524. else {
  2525. continue;
  2526. }
  2527. }
  2528. }
  2529. if (options.savedColors.length >= options.swatchLimit) {
  2530. disableButton(button, true);
  2531. }
  2532. else {
  2533. disableButton(button, false);
  2534. }
  2535. }
  2536. }
  2537. // Shows or hides edit swatches button depending on if there are saved swatches
  2538. function setEditButtonVisibility(enableButton) {
  2539. if (enableButton) {
  2540. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2541. butEdit.width = buttonWidth;
  2542. butEdit.height = buttonHeight;
  2543. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2544. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2545. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2546. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2547. butEdit.thickness = 2;
  2548. butEdit.color = buttonColor;
  2549. butEdit.fontSize = buttonFontSize;
  2550. butEdit.background = buttonBackgroundColor;
  2551. butEdit.onPointerEnterObservable.add(function () {
  2552. butEdit.background = buttonBackgroundHoverColor;
  2553. });
  2554. butEdit.onPointerOutObservable.add(function () {
  2555. butEdit.background = buttonBackgroundColor;
  2556. });
  2557. butEdit.pointerDownAnimation = function () {
  2558. butEdit.background = buttonBackgroundClickColor;
  2559. };
  2560. butEdit.pointerUpAnimation = function () {
  2561. butEdit.background = buttonBackgroundHoverColor;
  2562. };
  2563. butEdit.onPointerClickObservable.add(function () {
  2564. if (editSwatchMode) {
  2565. editSwatchMode = false;
  2566. }
  2567. else {
  2568. editSwatchMode = true;
  2569. }
  2570. editSwatches();
  2571. });
  2572. pickerGrid.addControl(butEdit, 1, 0);
  2573. }
  2574. else {
  2575. pickerGrid.removeControl(butEdit);
  2576. }
  2577. }
  2578. // Called when the user hits the limit of saved colors in the drawer.
  2579. function disableButton(button, disabled) {
  2580. if (disabled) {
  2581. button.color = buttonDisabledColor;
  2582. button.background = buttonDisabledBackgroundColor;
  2583. }
  2584. else {
  2585. button.color = buttonColor;
  2586. button.background = buttonBackgroundColor;
  2587. }
  2588. }
  2589. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2590. function closePicker(color) {
  2591. if (options.savedColors && options.savedColors.length > 0) {
  2592. resolve({
  2593. savedColors: options.savedColors,
  2594. pickedColor: color
  2595. });
  2596. }
  2597. else {
  2598. resolve({
  2599. pickedColor: color
  2600. });
  2601. }
  2602. advancedTexture.removeControl(dialogContainer);
  2603. }
  2604. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2605. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2606. dialogContainer.name = "Dialog Container";
  2607. dialogContainer.width = options.pickerWidth;
  2608. if (options.savedColors) {
  2609. dialogContainer.height = containerSize;
  2610. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2611. dialogContainer.addRowDefinition(topRow, false);
  2612. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2613. }
  2614. else {
  2615. dialogContainer.height = options.pickerHeight;
  2616. dialogContainer.addRowDefinition(1.0, false);
  2617. }
  2618. advancedTexture.addControl(dialogContainer);
  2619. // Swatch drawer which contains all saved color buttons
  2620. if (options.savedColors) {
  2621. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2622. swatchDrawer.name = "Swatch Drawer";
  2623. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2624. swatchDrawer.background = buttonBackgroundColor;
  2625. swatchDrawer.width = options.pickerWidth;
  2626. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2627. if (initialRows == 0) {
  2628. var gutterCount = 0;
  2629. }
  2630. else {
  2631. var gutterCount = initialRows + 1;
  2632. }
  2633. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2634. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2635. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2636. if (i % 2 != 0) {
  2637. swatchDrawer.addRowDefinition(swatchSize, true);
  2638. }
  2639. else {
  2640. swatchDrawer.addRowDefinition(gutterSize, true);
  2641. }
  2642. }
  2643. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2644. if (i % 2 != 0) {
  2645. swatchDrawer.addColumnDefinition(swatchSize, true);
  2646. }
  2647. else {
  2648. swatchDrawer.addColumnDefinition(gutterSize, true);
  2649. }
  2650. }
  2651. dialogContainer.addControl(swatchDrawer, 1, 0);
  2652. }
  2653. // Picker container
  2654. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2655. pickerPanel.name = "Picker Panel";
  2656. pickerPanel.height = options.pickerHeight;
  2657. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2658. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2659. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2660. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2661. dialogContainer.addControl(pickerPanel, 0, 0);
  2662. // Picker container header
  2663. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2664. header.name = "Dialogue Header Bar";
  2665. header.background = "#cccccc";
  2666. header.thickness = 0;
  2667. pickerPanel.addControl(header, 0, 0);
  2668. // Header close button
  2669. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2670. closeButton.fontFamily = "BabylonJSglyphs";
  2671. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2672. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2673. closeButton.color = closeIconColor.toHexString();
  2674. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2675. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2676. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2677. closeButton.height = closeButton.width = options.headerHeight;
  2678. closeButton.background = header.background;
  2679. closeButton.thickness = 0;
  2680. closeButton.pointerDownAnimation = function () {
  2681. };
  2682. closeButton.pointerUpAnimation = function () {
  2683. closeButton.background = header.background;
  2684. };
  2685. closeButton.pointerEnterAnimation = function () {
  2686. closeButton.color = header.background;
  2687. closeButton.background = "red";
  2688. };
  2689. closeButton.pointerOutAnimation = function () {
  2690. closeButton.color = closeIconColor.toHexString();
  2691. closeButton.background = header.background;
  2692. };
  2693. closeButton.onPointerClickObservable.add(function () {
  2694. closePicker(currentSwatch.background);
  2695. });
  2696. pickerPanel.addControl(closeButton, 0, 0);
  2697. // Dialog container body
  2698. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2699. dialogBody.name = "Dialogue Body";
  2700. dialogBody.background = buttonBackgroundColor;
  2701. var dialogBodyCols = [0.4375, 0.5625];
  2702. dialogBody.addRowDefinition(1.0, false);
  2703. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2704. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2705. pickerPanel.addControl(dialogBody, 1, 0);
  2706. // Picker grid
  2707. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2708. pickerGrid.name = "Picker Grid";
  2709. pickerGrid.addRowDefinition(0.85, false);
  2710. pickerGrid.addRowDefinition(0.15, false);
  2711. dialogBody.addControl(pickerGrid, 0, 0);
  2712. // Picker control
  2713. picker = new ColorPicker();
  2714. picker.name = "GUI Color Picker";
  2715. if (options.pickerHeight < options.pickerWidth) {
  2716. picker.width = 0.89;
  2717. }
  2718. else {
  2719. picker.height = 0.89;
  2720. }
  2721. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2722. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2723. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2724. picker.onPointerDownObservable.add(function () {
  2725. activeField = picker.name;
  2726. lastVal = "";
  2727. editSwatches(false);
  2728. });
  2729. picker.onValueChangedObservable.add(function (value) {
  2730. if (activeField == picker.name) {
  2731. updateValues(value, picker.name);
  2732. }
  2733. });
  2734. pickerGrid.addControl(picker, 0, 0);
  2735. // Picker body right quarant
  2736. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2737. pickerBodyRight.name = "Dialogue Right Half";
  2738. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2739. var pickerBodyRightRows = [0.514, 0.486];
  2740. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2741. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2742. dialogBody.addControl(pickerBodyRight, 1, 1);
  2743. // Picker container swatches and buttons
  2744. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2745. pickerSwatchesButtons.name = "Swatches and Buttons";
  2746. var pickerButtonsCol = [0.417, 0.583];
  2747. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2748. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2749. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2750. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2751. // Picker Swatches quadrant
  2752. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2753. pickerSwatches.name = "New and Current Swatches";
  2754. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2755. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2756. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2757. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2758. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2759. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2760. // Active swatches
  2761. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2762. activeSwatches.name = "Active Swatches";
  2763. activeSwatches.width = 0.67;
  2764. activeSwatches.addRowDefinition(0.5, false);
  2765. activeSwatches.addRowDefinition(0.5, false);
  2766. pickerSwatches.addControl(activeSwatches, 2, 0);
  2767. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2768. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2769. if (options.pickerWidth > options.pickerHeight) {
  2770. var labelTextSize = labelHeight;
  2771. }
  2772. else {
  2773. var labelTextSize = labelWidth;
  2774. }
  2775. // New color swatch and previous color button
  2776. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2777. newText.text = "new";
  2778. newText.name = "New Color Label";
  2779. newText.color = buttonColor;
  2780. newText.fontSize = labelTextSize;
  2781. pickerSwatches.addControl(newText, 1, 0);
  2782. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2783. newSwatch.name = "New Color Swatch";
  2784. newSwatch.background = options.lastColor;
  2785. newSwatch.thickness = 0;
  2786. activeSwatches.addControl(newSwatch, 0, 0);
  2787. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2788. currentSwatch.background = options.lastColor;
  2789. currentSwatch.thickness = 0;
  2790. currentSwatch.onPointerClickObservable.add(function () {
  2791. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2792. updateValues(revertColor, currentSwatch.name);
  2793. editSwatches(false);
  2794. });
  2795. currentSwatch.pointerDownAnimation = function () { };
  2796. currentSwatch.pointerUpAnimation = function () { };
  2797. currentSwatch.pointerEnterAnimation = function () { };
  2798. currentSwatch.pointerOutAnimation = function () { };
  2799. activeSwatches.addControl(currentSwatch, 1, 0);
  2800. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2801. swatchOutline.name = "Swatch Outline";
  2802. swatchOutline.width = 0.67;
  2803. swatchOutline.thickness = 2;
  2804. swatchOutline.color = currentSwatchesOutlineColor;
  2805. swatchOutline.isHitTestVisible = false;
  2806. pickerSwatches.addControl(swatchOutline, 2, 0);
  2807. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2808. currentText.name = "Current Color Label";
  2809. currentText.text = "current";
  2810. currentText.color = buttonColor;
  2811. currentText.fontSize = labelTextSize;
  2812. pickerSwatches.addControl(currentText, 3, 0);
  2813. // Buttons grid
  2814. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2815. buttonGrid.name = "Button Grid";
  2816. buttonGrid.height = 0.8;
  2817. var buttonGridRows = 1 / 3;
  2818. buttonGrid.addRowDefinition(buttonGridRows, false);
  2819. buttonGrid.addRowDefinition(buttonGridRows, false);
  2820. buttonGrid.addRowDefinition(buttonGridRows, false);
  2821. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2822. // Determine pixel width and height for all buttons from overall panel dimensions
  2823. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2824. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2825. // Determine button type size
  2826. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2827. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2828. }
  2829. else {
  2830. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2831. }
  2832. // Panel Buttons
  2833. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2834. butOK.width = buttonWidth;
  2835. butOK.height = buttonHeight;
  2836. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2837. butOK.thickness = 2;
  2838. butOK.color = buttonColor;
  2839. butOK.fontSize = buttonFontSize;
  2840. butOK.background = buttonBackgroundColor;
  2841. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2842. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2843. butOK.pointerDownAnimation = function () {
  2844. butOK.background = buttonBackgroundClickColor;
  2845. };
  2846. butOK.pointerUpAnimation = function () {
  2847. butOK.background = buttonBackgroundHoverColor;
  2848. };
  2849. butOK.onPointerClickObservable.add(function () {
  2850. editSwatches(false);
  2851. closePicker(newSwatch.background);
  2852. });
  2853. buttonGrid.addControl(butOK, 0, 0);
  2854. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2855. butCancel.width = buttonWidth;
  2856. butCancel.height = buttonHeight;
  2857. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2858. butCancel.thickness = 2;
  2859. butCancel.color = buttonColor;
  2860. butCancel.fontSize = buttonFontSize;
  2861. butCancel.background = buttonBackgroundColor;
  2862. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2863. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2864. butCancel.pointerDownAnimation = function () {
  2865. butCancel.background = buttonBackgroundClickColor;
  2866. };
  2867. butCancel.pointerUpAnimation = function () {
  2868. butCancel.background = buttonBackgroundHoverColor;
  2869. };
  2870. butCancel.onPointerClickObservable.add(function () {
  2871. editSwatches(false);
  2872. closePicker(currentSwatch.background);
  2873. });
  2874. buttonGrid.addControl(butCancel, 1, 0);
  2875. if (options.savedColors) {
  2876. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2877. butSave.width = buttonWidth;
  2878. butSave.height = buttonHeight;
  2879. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2880. butSave.thickness = 2;
  2881. butSave.fontSize = buttonFontSize;
  2882. if (options.savedColors.length < options.swatchLimit) {
  2883. butSave.color = buttonColor;
  2884. butSave.background = buttonBackgroundColor;
  2885. }
  2886. else {
  2887. disableButton(butSave, true);
  2888. }
  2889. butSave.onPointerEnterObservable.add(function () {
  2890. if (options.savedColors) {
  2891. if (options.savedColors.length < options.swatchLimit) {
  2892. butSave.background = buttonBackgroundHoverColor;
  2893. }
  2894. }
  2895. });
  2896. butSave.onPointerOutObservable.add(function () {
  2897. if (options.savedColors) {
  2898. if (options.savedColors.length < options.swatchLimit) {
  2899. butSave.background = buttonBackgroundColor;
  2900. }
  2901. }
  2902. });
  2903. butSave.pointerDownAnimation = function () {
  2904. if (options.savedColors) {
  2905. if (options.savedColors.length < options.swatchLimit) {
  2906. butSave.background = buttonBackgroundClickColor;
  2907. }
  2908. }
  2909. };
  2910. butSave.pointerUpAnimation = function () {
  2911. if (options.savedColors) {
  2912. if (options.savedColors.length < options.swatchLimit) {
  2913. butSave.background = buttonBackgroundHoverColor;
  2914. }
  2915. }
  2916. };
  2917. butSave.onPointerClickObservable.add(function () {
  2918. if (options.savedColors) {
  2919. if (options.savedColors.length == 0) {
  2920. setEditButtonVisibility(true);
  2921. }
  2922. if (options.savedColors.length < options.swatchLimit) {
  2923. updateSwatches(newSwatch.background, butSave);
  2924. }
  2925. editSwatches(false);
  2926. }
  2927. });
  2928. if (options.savedColors.length > 0) {
  2929. setEditButtonVisibility(true);
  2930. }
  2931. buttonGrid.addControl(butSave, 2, 0);
  2932. }
  2933. // Picker color values input
  2934. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2935. pickerColorValues.name = "Dialog Lower Right";
  2936. pickerColorValues.addRowDefinition(0.02, false);
  2937. pickerColorValues.addRowDefinition(0.63, false);
  2938. pickerColorValues.addRowDefinition(0.21, false);
  2939. pickerColorValues.addRowDefinition(0.14, false);
  2940. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2941. // RGB values text boxes
  2942. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2943. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2944. rgbValuesQuadrant.name = "RGB Values";
  2945. rgbValuesQuadrant.width = 0.82;
  2946. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2947. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2948. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2949. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2950. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2951. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2952. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2953. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2954. for (var i = 0; i < inputFieldLabels.length; i++) {
  2955. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2956. labelText.text = inputFieldLabels[i];
  2957. labelText.color = buttonColor;
  2958. labelText.fontSize = buttonFontSize;
  2959. rgbValuesQuadrant.addControl(labelText, i, 0);
  2960. }
  2961. // Input fields for RGB values
  2962. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2963. rValInt.width = 0.83;
  2964. rValInt.height = 0.72;
  2965. rValInt.name = "rIntField";
  2966. rValInt.fontSize = buttonFontSize;
  2967. rValInt.text = (currentColor.r * 255).toString();
  2968. rValInt.color = inputTextColor;
  2969. rValInt.background = inputTextBackgroundColor;
  2970. rValInt.onFocusObservable.add(function () {
  2971. activeField = rValInt.name;
  2972. lastVal = rValInt.text;
  2973. editSwatches(false);
  2974. });
  2975. rValInt.onBlurObservable.add(function () {
  2976. if (rValInt.text == "") {
  2977. rValInt.text = "0";
  2978. }
  2979. updateInt(rValInt, "r");
  2980. if (activeField == rValInt.name) {
  2981. activeField = "";
  2982. }
  2983. });
  2984. rValInt.onTextChangedObservable.add(function () {
  2985. if (activeField == rValInt.name) {
  2986. updateInt(rValInt, "r");
  2987. }
  2988. });
  2989. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2990. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2991. gValInt.width = 0.83;
  2992. gValInt.height = 0.72;
  2993. gValInt.name = "gIntField";
  2994. gValInt.fontSize = buttonFontSize;
  2995. gValInt.text = (currentColor.g * 255).toString();
  2996. gValInt.color = inputTextColor;
  2997. gValInt.background = inputTextBackgroundColor;
  2998. gValInt.onFocusObservable.add(function () {
  2999. activeField = gValInt.name;
  3000. lastVal = gValInt.text;
  3001. editSwatches(false);
  3002. });
  3003. gValInt.onBlurObservable.add(function () {
  3004. if (gValInt.text == "") {
  3005. gValInt.text = "0";
  3006. }
  3007. updateInt(gValInt, "g");
  3008. if (activeField == gValInt.name) {
  3009. activeField = "";
  3010. }
  3011. });
  3012. gValInt.onTextChangedObservable.add(function () {
  3013. if (activeField == gValInt.name) {
  3014. updateInt(gValInt, "g");
  3015. }
  3016. });
  3017. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3018. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3019. bValInt.width = 0.83;
  3020. bValInt.height = 0.72;
  3021. bValInt.name = "bIntField";
  3022. bValInt.fontSize = buttonFontSize;
  3023. bValInt.text = (currentColor.b * 255).toString();
  3024. bValInt.color = inputTextColor;
  3025. bValInt.background = inputTextBackgroundColor;
  3026. bValInt.onFocusObservable.add(function () {
  3027. activeField = bValInt.name;
  3028. lastVal = bValInt.text;
  3029. editSwatches(false);
  3030. });
  3031. bValInt.onBlurObservable.add(function () {
  3032. if (bValInt.text == "") {
  3033. bValInt.text = "0";
  3034. }
  3035. updateInt(bValInt, "b");
  3036. if (activeField == bValInt.name) {
  3037. activeField = "";
  3038. }
  3039. });
  3040. bValInt.onTextChangedObservable.add(function () {
  3041. if (activeField == bValInt.name) {
  3042. updateInt(bValInt, "b");
  3043. }
  3044. });
  3045. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3046. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3047. rValDec.width = 0.95;
  3048. rValDec.height = 0.72;
  3049. rValDec.name = "rDecField";
  3050. rValDec.fontSize = buttonFontSize;
  3051. rValDec.text = currentColor.r.toString();
  3052. rValDec.color = inputTextColor;
  3053. rValDec.background = inputTextBackgroundColor;
  3054. rValDec.onFocusObservable.add(function () {
  3055. activeField = rValDec.name;
  3056. lastVal = rValDec.text;
  3057. editSwatches(false);
  3058. });
  3059. rValDec.onBlurObservable.add(function () {
  3060. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3061. rValDec.text = "0";
  3062. updateFloat(rValDec, "r");
  3063. }
  3064. if (activeField == rValDec.name) {
  3065. activeField = "";
  3066. }
  3067. });
  3068. rValDec.onTextChangedObservable.add(function () {
  3069. if (activeField == rValDec.name) {
  3070. updateFloat(rValDec, "r");
  3071. }
  3072. });
  3073. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3074. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3075. gValDec.width = 0.95;
  3076. gValDec.height = 0.72;
  3077. gValDec.name = "gDecField";
  3078. gValDec.fontSize = buttonFontSize;
  3079. gValDec.text = currentColor.g.toString();
  3080. gValDec.color = inputTextColor;
  3081. gValDec.background = inputTextBackgroundColor;
  3082. gValDec.onFocusObservable.add(function () {
  3083. activeField = gValDec.name;
  3084. lastVal = gValDec.text;
  3085. editSwatches(false);
  3086. });
  3087. gValDec.onBlurObservable.add(function () {
  3088. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3089. gValDec.text = "0";
  3090. updateFloat(gValDec, "g");
  3091. }
  3092. if (activeField == gValDec.name) {
  3093. activeField = "";
  3094. }
  3095. });
  3096. gValDec.onTextChangedObservable.add(function () {
  3097. if (activeField == gValDec.name) {
  3098. updateFloat(gValDec, "g");
  3099. }
  3100. });
  3101. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3102. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3103. bValDec.width = 0.95;
  3104. bValDec.height = 0.72;
  3105. bValDec.name = "bDecField";
  3106. bValDec.fontSize = buttonFontSize;
  3107. bValDec.text = currentColor.b.toString();
  3108. bValDec.color = inputTextColor;
  3109. bValDec.background = inputTextBackgroundColor;
  3110. bValDec.onFocusObservable.add(function () {
  3111. activeField = bValDec.name;
  3112. lastVal = bValDec.text;
  3113. editSwatches(false);
  3114. });
  3115. bValDec.onBlurObservable.add(function () {
  3116. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3117. bValDec.text = "0";
  3118. updateFloat(bValDec, "b");
  3119. }
  3120. if (activeField == bValDec.name) {
  3121. activeField = "";
  3122. }
  3123. });
  3124. bValDec.onTextChangedObservable.add(function () {
  3125. if (activeField == bValDec.name) {
  3126. updateFloat(bValDec, "b");
  3127. }
  3128. });
  3129. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3130. // Hex value input
  3131. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3132. hexValueQuadrant.name = "Hex Value";
  3133. hexValueQuadrant.width = 0.82;
  3134. hexValueQuadrant.addRowDefinition(1.0, false);
  3135. hexValueQuadrant.addColumnDefinition(0.1, false);
  3136. hexValueQuadrant.addColumnDefinition(0.9, false);
  3137. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3138. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3139. labelText.text = "#";
  3140. labelText.color = buttonColor;
  3141. labelText.fontSize = buttonFontSize;
  3142. hexValueQuadrant.addControl(labelText, 0, 0);
  3143. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3144. hexVal.width = 0.96;
  3145. hexVal.height = 0.72;
  3146. hexVal.name = "hexField";
  3147. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3148. hexVal.fontSize = buttonFontSize;
  3149. var minusPound = options.lastColor.split("#");
  3150. hexVal.text = minusPound[1];
  3151. hexVal.color = inputTextColor;
  3152. hexVal.background = inputTextBackgroundColor;
  3153. hexVal.onFocusObservable.add(function () {
  3154. activeField = hexVal.name;
  3155. lastVal = hexVal.text;
  3156. editSwatches(false);
  3157. });
  3158. hexVal.onBlurObservable.add(function () {
  3159. if (hexVal.text.length == 3) {
  3160. var val = hexVal.text.split("");
  3161. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3162. }
  3163. if (hexVal.text == "") {
  3164. hexVal.text = "000000";
  3165. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3166. }
  3167. if (activeField == hexVal.name) {
  3168. activeField = "";
  3169. }
  3170. });
  3171. hexVal.onTextChangedObservable.add(function () {
  3172. var newHexValue = hexVal.text;
  3173. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3174. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3175. hexVal.text = lastVal;
  3176. }
  3177. else {
  3178. if (hexVal.text.length < 6) {
  3179. var leadingZero = 6 - hexVal.text.length;
  3180. for (var i = 0; i < leadingZero; i++) {
  3181. newHexValue = "0" + newHexValue;
  3182. }
  3183. }
  3184. if (hexVal.text.length == 3) {
  3185. var val = hexVal.text.split("");
  3186. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3187. }
  3188. newHexValue = "#" + newHexValue;
  3189. if (activeField == hexVal.name) {
  3190. lastVal = hexVal.text;
  3191. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3192. }
  3193. }
  3194. });
  3195. hexValueQuadrant.addControl(hexVal, 0, 1);
  3196. if (options.savedColors && options.savedColors.length > 0) {
  3197. updateSwatches("", butSave);
  3198. }
  3199. });
  3200. };
  3201. ColorPicker._Epsilon = 0.000001;
  3202. return ColorPicker;
  3203. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3204. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3205. /***/ }),
  3206. /***/ "./2D/controls/container.ts":
  3207. /*!**********************************!*\
  3208. !*** ./2D/controls/container.ts ***!
  3209. \**********************************/
  3210. /*! exports provided: Container */
  3211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3212. "use strict";
  3213. __webpack_require__.r(__webpack_exports__);
  3214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3215. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3216. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3217. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3218. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3219. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3220. /**
  3221. * Root class for 2D containers
  3222. * @see https://doc.babylonjs.com/how_to/gui#containers
  3223. */
  3224. var Container = /** @class */ (function (_super) {
  3225. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3226. /**
  3227. * Creates a new Container
  3228. * @param name defines the name of the container
  3229. */
  3230. function Container(name) {
  3231. var _this = _super.call(this, name) || this;
  3232. _this.name = name;
  3233. /** @hidden */
  3234. _this._children = new Array();
  3235. /** @hidden */
  3236. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3237. /** @hidden */
  3238. _this._background = "";
  3239. /** @hidden */
  3240. _this._adaptWidthToChildren = false;
  3241. /** @hidden */
  3242. _this._adaptHeightToChildren = false;
  3243. /**
  3244. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3245. */
  3246. _this.logLayoutCycleErrors = false;
  3247. /**
  3248. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3249. */
  3250. _this.maxLayoutCycle = 3;
  3251. return _this;
  3252. }
  3253. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3254. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3255. get: function () {
  3256. return this._adaptHeightToChildren;
  3257. },
  3258. set: function (value) {
  3259. if (this._adaptHeightToChildren === value) {
  3260. return;
  3261. }
  3262. this._adaptHeightToChildren = value;
  3263. if (value) {
  3264. this.height = "100%";
  3265. }
  3266. this._markAsDirty();
  3267. },
  3268. enumerable: false,
  3269. configurable: true
  3270. });
  3271. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3272. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3273. get: function () {
  3274. return this._adaptWidthToChildren;
  3275. },
  3276. set: function (value) {
  3277. if (this._adaptWidthToChildren === value) {
  3278. return;
  3279. }
  3280. this._adaptWidthToChildren = value;
  3281. if (value) {
  3282. this.width = "100%";
  3283. }
  3284. this._markAsDirty();
  3285. },
  3286. enumerable: false,
  3287. configurable: true
  3288. });
  3289. Object.defineProperty(Container.prototype, "background", {
  3290. /** Gets or sets background color */
  3291. get: function () {
  3292. return this._background;
  3293. },
  3294. set: function (value) {
  3295. if (this._background === value) {
  3296. return;
  3297. }
  3298. this._background = value;
  3299. this._markAsDirty();
  3300. },
  3301. enumerable: false,
  3302. configurable: true
  3303. });
  3304. Object.defineProperty(Container.prototype, "children", {
  3305. /** Gets the list of children */
  3306. get: function () {
  3307. return this._children;
  3308. },
  3309. enumerable: false,
  3310. configurable: true
  3311. });
  3312. Container.prototype._getTypeName = function () {
  3313. return "Container";
  3314. };
  3315. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3316. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3317. var child = _a[_i];
  3318. child._markMatrixAsDirty();
  3319. }
  3320. };
  3321. /**
  3322. * Gets a child using its name
  3323. * @param name defines the child name to look for
  3324. * @returns the child control if found
  3325. */
  3326. Container.prototype.getChildByName = function (name) {
  3327. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3328. var child = _a[_i];
  3329. if (child.name === name) {
  3330. return child;
  3331. }
  3332. }
  3333. return null;
  3334. };
  3335. /**
  3336. * Gets a child using its type and its name
  3337. * @param name defines the child name to look for
  3338. * @param type defines the child type to look for
  3339. * @returns the child control if found
  3340. */
  3341. Container.prototype.getChildByType = function (name, type) {
  3342. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3343. var child = _a[_i];
  3344. if (child.typeName === type) {
  3345. return child;
  3346. }
  3347. }
  3348. return null;
  3349. };
  3350. /**
  3351. * Search for a specific control in children
  3352. * @param control defines the control to look for
  3353. * @returns true if the control is in child list
  3354. */
  3355. Container.prototype.containsControl = function (control) {
  3356. return this.children.indexOf(control) !== -1;
  3357. };
  3358. /**
  3359. * Adds a new control to the current container
  3360. * @param control defines the control to add
  3361. * @returns the current container
  3362. */
  3363. Container.prototype.addControl = function (control) {
  3364. if (!control) {
  3365. return this;
  3366. }
  3367. var index = this._children.indexOf(control);
  3368. if (index !== -1) {
  3369. return this;
  3370. }
  3371. control._link(this._host);
  3372. control._markAllAsDirty();
  3373. this._reOrderControl(control);
  3374. this._markAsDirty();
  3375. return this;
  3376. };
  3377. /**
  3378. * Removes all controls from the current container
  3379. * @returns the current container
  3380. */
  3381. Container.prototype.clearControls = function () {
  3382. var children = this.children.slice();
  3383. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3384. var child = children_1[_i];
  3385. this.removeControl(child);
  3386. }
  3387. return this;
  3388. };
  3389. /**
  3390. * Removes a control from the current container
  3391. * @param control defines the control to remove
  3392. * @returns the current container
  3393. */
  3394. Container.prototype.removeControl = function (control) {
  3395. var index = this._children.indexOf(control);
  3396. if (index !== -1) {
  3397. this._children.splice(index, 1);
  3398. control.parent = null;
  3399. }
  3400. control.linkWithMesh(null);
  3401. if (this._host) {
  3402. this._host._cleanControlAfterRemoval(control);
  3403. }
  3404. this._markAsDirty();
  3405. return this;
  3406. };
  3407. /** @hidden */
  3408. Container.prototype._reOrderControl = function (control) {
  3409. this.removeControl(control);
  3410. var wasAdded = false;
  3411. for (var index = 0; index < this._children.length; index++) {
  3412. if (this._children[index].zIndex > control.zIndex) {
  3413. this._children.splice(index, 0, control);
  3414. wasAdded = true;
  3415. break;
  3416. }
  3417. }
  3418. if (!wasAdded) {
  3419. this._children.push(control);
  3420. }
  3421. control.parent = this;
  3422. this._markAsDirty();
  3423. };
  3424. /** @hidden */
  3425. Container.prototype._offsetLeft = function (offset) {
  3426. _super.prototype._offsetLeft.call(this, offset);
  3427. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3428. var child = _a[_i];
  3429. child._offsetLeft(offset);
  3430. }
  3431. };
  3432. /** @hidden */
  3433. Container.prototype._offsetTop = function (offset) {
  3434. _super.prototype._offsetTop.call(this, offset);
  3435. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3436. var child = _a[_i];
  3437. child._offsetTop(offset);
  3438. }
  3439. };
  3440. /** @hidden */
  3441. Container.prototype._markAllAsDirty = function () {
  3442. _super.prototype._markAllAsDirty.call(this);
  3443. for (var index = 0; index < this._children.length; index++) {
  3444. this._children[index]._markAllAsDirty();
  3445. }
  3446. };
  3447. /** @hidden */
  3448. Container.prototype._localDraw = function (context) {
  3449. if (this._background) {
  3450. context.save();
  3451. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3452. context.shadowColor = this.shadowColor;
  3453. context.shadowBlur = this.shadowBlur;
  3454. context.shadowOffsetX = this.shadowOffsetX;
  3455. context.shadowOffsetY = this.shadowOffsetY;
  3456. }
  3457. context.fillStyle = this._background;
  3458. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3459. context.restore();
  3460. }
  3461. };
  3462. /** @hidden */
  3463. Container.prototype._link = function (host) {
  3464. _super.prototype._link.call(this, host);
  3465. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3466. var child = _a[_i];
  3467. child._link(host);
  3468. }
  3469. };
  3470. /** @hidden */
  3471. Container.prototype._beforeLayout = function () {
  3472. // Do nothing
  3473. };
  3474. /** @hidden */
  3475. Container.prototype._processMeasures = function (parentMeasure, context) {
  3476. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3477. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3478. this._evaluateClippingState(parentMeasure);
  3479. }
  3480. };
  3481. /** @hidden */
  3482. Container.prototype._layout = function (parentMeasure, context) {
  3483. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3484. return false;
  3485. }
  3486. this.host._numLayoutCalls++;
  3487. if (this._isDirty) {
  3488. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3489. }
  3490. var rebuildCount = 0;
  3491. context.save();
  3492. this._applyStates(context);
  3493. this._beforeLayout();
  3494. do {
  3495. var computedWidth = -1;
  3496. var computedHeight = -1;
  3497. this._rebuildLayout = false;
  3498. this._processMeasures(parentMeasure, context);
  3499. if (!this._isClipped) {
  3500. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3501. var child = _a[_i];
  3502. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3503. if (child._layout(this._measureForChildren, context)) {
  3504. if (this.adaptWidthToChildren && child._width.isPixel) {
  3505. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3506. }
  3507. if (this.adaptHeightToChildren && child._height.isPixel) {
  3508. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3509. }
  3510. }
  3511. }
  3512. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3513. if (this.width !== computedWidth + "px") {
  3514. this.width = computedWidth + "px";
  3515. this._rebuildLayout = true;
  3516. }
  3517. }
  3518. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3519. if (this.height !== computedHeight + "px") {
  3520. this.height = computedHeight + "px";
  3521. this._rebuildLayout = true;
  3522. }
  3523. }
  3524. this._postMeasure();
  3525. }
  3526. rebuildCount++;
  3527. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3528. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3529. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3530. }
  3531. context.restore();
  3532. if (this._isDirty) {
  3533. this.invalidateRect();
  3534. this._isDirty = false;
  3535. }
  3536. return true;
  3537. };
  3538. Container.prototype._postMeasure = function () {
  3539. // Do nothing by default
  3540. };
  3541. /** @hidden */
  3542. Container.prototype._draw = function (context, invalidatedRectangle) {
  3543. this._localDraw(context);
  3544. if (this.clipChildren) {
  3545. this._clipForChildren(context);
  3546. }
  3547. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3548. var child = _a[_i];
  3549. // Only redraw parts of the screen that are invalidated
  3550. if (invalidatedRectangle) {
  3551. if (!child._intersectsRect(invalidatedRectangle)) {
  3552. continue;
  3553. }
  3554. }
  3555. child._render(context, invalidatedRectangle);
  3556. }
  3557. };
  3558. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3559. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3560. if (!this.children) {
  3561. return;
  3562. }
  3563. for (var index = 0; index < this.children.length; index++) {
  3564. var item = this.children[index];
  3565. if (!predicate || predicate(item)) {
  3566. results.push(item);
  3567. }
  3568. if (!directDescendantsOnly) {
  3569. item.getDescendantsToRef(results, false, predicate);
  3570. }
  3571. }
  3572. };
  3573. /** @hidden */
  3574. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  3575. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3576. return false;
  3577. }
  3578. if (!_super.prototype.contains.call(this, x, y)) {
  3579. return false;
  3580. }
  3581. // Checking backwards to pick closest first
  3582. for (var index = this._children.length - 1; index >= 0; index--) {
  3583. var child = this._children[index];
  3584. if (child._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3585. if (child.hoverCursor) {
  3586. this._host._changeCursor(child.hoverCursor);
  3587. }
  3588. return true;
  3589. }
  3590. }
  3591. if (!this.isHitTestVisible) {
  3592. return false;
  3593. }
  3594. return this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  3595. };
  3596. /** @hidden */
  3597. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3598. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3599. this._measureForChildren.copyFrom(this._currentMeasure);
  3600. };
  3601. /** Releases associated resources */
  3602. Container.prototype.dispose = function () {
  3603. _super.prototype.dispose.call(this);
  3604. for (var index = this.children.length - 1; index >= 0; index--) {
  3605. this.children[index].dispose();
  3606. }
  3607. };
  3608. return Container;
  3609. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3610. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3611. /***/ }),
  3612. /***/ "./2D/controls/control.ts":
  3613. /*!********************************!*\
  3614. !*** ./2D/controls/control.ts ***!
  3615. \********************************/
  3616. /*! exports provided: Control */
  3617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3618. "use strict";
  3619. __webpack_require__.r(__webpack_exports__);
  3620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3621. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3622. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3623. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3624. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3625. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3626. /**
  3627. * Root class used for all 2D controls
  3628. * @see https://doc.babylonjs.com/how_to/gui#controls
  3629. */
  3630. var Control = /** @class */ (function () {
  3631. // Functions
  3632. /**
  3633. * Creates a new control
  3634. * @param name defines the name of the control
  3635. */
  3636. function Control(
  3637. /** defines the name of the control */
  3638. name) {
  3639. this.name = name;
  3640. this._alpha = 1;
  3641. this._alphaSet = false;
  3642. this._zIndex = 0;
  3643. /** @hidden */
  3644. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3645. this._fontFamily = "Arial";
  3646. this._fontStyle = "";
  3647. this._fontWeight = "";
  3648. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3649. /** @hidden */
  3650. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3651. /** @hidden */
  3652. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3653. this._color = "";
  3654. this._style = null;
  3655. /** @hidden */
  3656. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3657. /** @hidden */
  3658. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3659. /** @hidden */
  3660. this._isDirty = true;
  3661. /** @hidden */
  3662. this._wasDirty = false;
  3663. /** @hidden */
  3664. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3665. /** @hidden */
  3666. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3667. /** @hidden */
  3668. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3669. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3670. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3671. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3672. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3673. /** @hidden */
  3674. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3675. /** @hidden */
  3676. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3677. this._scaleX = 1.0;
  3678. this._scaleY = 1.0;
  3679. this._rotation = 0;
  3680. this._transformCenterX = 0.5;
  3681. this._transformCenterY = 0.5;
  3682. /** @hidden */
  3683. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3684. /** @hidden */
  3685. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3686. /** @hidden */
  3687. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3688. this._isMatrixDirty = true;
  3689. this._isVisible = true;
  3690. this._isHighlighted = false;
  3691. this._fontSet = false;
  3692. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3693. this._downCount = 0;
  3694. this._enterCount = -1;
  3695. this._doNotRender = false;
  3696. this._downPointerIds = {};
  3697. this._isEnabled = true;
  3698. this._disabledColor = "#9a9a9a";
  3699. this._disabledColorItem = "#6a6a6a";
  3700. /** @hidden */
  3701. this._rebuildLayout = false;
  3702. /** @hidden */
  3703. this._customData = {};
  3704. /** @hidden */
  3705. this._isClipped = false;
  3706. /** @hidden */
  3707. this._automaticSize = false;
  3708. /**
  3709. * Gets or sets an object used to store user defined information for the node
  3710. */
  3711. this.metadata = null;
  3712. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3713. this.isHitTestVisible = true;
  3714. /** Gets or sets a boolean indicating if the control can block pointer events */
  3715. this.isPointerBlocker = false;
  3716. /** Gets or sets a boolean indicating if the control can be focusable */
  3717. this.isFocusInvisible = false;
  3718. /**
  3719. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3720. * 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
  3721. */
  3722. this.clipChildren = true;
  3723. /**
  3724. * Gets or sets a boolean indicating that control content must be clipped
  3725. * 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
  3726. */
  3727. this.clipContent = true;
  3728. /**
  3729. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3730. */
  3731. this.useBitmapCache = false;
  3732. this._shadowOffsetX = 0;
  3733. this._shadowOffsetY = 0;
  3734. this._shadowBlur = 0;
  3735. this._shadowColor = 'black';
  3736. /** Gets or sets the cursor to use when the control is hovered */
  3737. this.hoverCursor = "";
  3738. /** @hidden */
  3739. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3740. /** @hidden */
  3741. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3742. /**
  3743. * An event triggered when pointer wheel is scrolled
  3744. */
  3745. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3746. /**
  3747. * An event triggered when the pointer move over the control.
  3748. */
  3749. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3750. /**
  3751. * An event triggered when the pointer move out of the control.
  3752. */
  3753. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3754. /**
  3755. * An event triggered when the pointer taps the control
  3756. */
  3757. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3758. /**
  3759. * An event triggered when pointer up
  3760. */
  3761. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3762. /**
  3763. * An event triggered when a control is clicked on
  3764. */
  3765. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3766. /**
  3767. * An event triggered when pointer enters the control
  3768. */
  3769. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3770. /**
  3771. * An event triggered when the control is marked as dirty
  3772. */
  3773. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3774. /**
  3775. * An event triggered before drawing the control
  3776. */
  3777. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3778. /**
  3779. * An event triggered after the control was drawn
  3780. */
  3781. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3782. /**
  3783. * An event triggered when the control has been disposed
  3784. */
  3785. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3786. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3787. }
  3788. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3789. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3790. get: function () {
  3791. return this._shadowOffsetX;
  3792. },
  3793. set: function (value) {
  3794. if (this._shadowOffsetX === value) {
  3795. return;
  3796. }
  3797. this._shadowOffsetX = value;
  3798. this._markAsDirty();
  3799. },
  3800. enumerable: false,
  3801. configurable: true
  3802. });
  3803. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3804. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3805. get: function () {
  3806. return this._shadowOffsetY;
  3807. },
  3808. set: function (value) {
  3809. if (this._shadowOffsetY === value) {
  3810. return;
  3811. }
  3812. this._shadowOffsetY = value;
  3813. this._markAsDirty();
  3814. },
  3815. enumerable: false,
  3816. configurable: true
  3817. });
  3818. Object.defineProperty(Control.prototype, "shadowBlur", {
  3819. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3820. get: function () {
  3821. return this._shadowBlur;
  3822. },
  3823. set: function (value) {
  3824. if (this._shadowBlur === value) {
  3825. return;
  3826. }
  3827. this._shadowBlur = value;
  3828. this._markAsDirty();
  3829. },
  3830. enumerable: false,
  3831. configurable: true
  3832. });
  3833. Object.defineProperty(Control.prototype, "shadowColor", {
  3834. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3835. get: function () {
  3836. return this._shadowColor;
  3837. },
  3838. set: function (value) {
  3839. if (this._shadowColor === value) {
  3840. return;
  3841. }
  3842. this._shadowColor = value;
  3843. this._markAsDirty();
  3844. },
  3845. enumerable: false,
  3846. configurable: true
  3847. });
  3848. Object.defineProperty(Control.prototype, "typeName", {
  3849. // Properties
  3850. /** Gets the control type name */
  3851. get: function () {
  3852. return this._getTypeName();
  3853. },
  3854. enumerable: false,
  3855. configurable: true
  3856. });
  3857. /**
  3858. * Get the current class name of the control.
  3859. * @returns current class name
  3860. */
  3861. Control.prototype.getClassName = function () {
  3862. return this._getTypeName();
  3863. };
  3864. Object.defineProperty(Control.prototype, "host", {
  3865. /**
  3866. * Get the hosting AdvancedDynamicTexture
  3867. */
  3868. get: function () {
  3869. return this._host;
  3870. },
  3871. enumerable: false,
  3872. configurable: true
  3873. });
  3874. Object.defineProperty(Control.prototype, "fontOffset", {
  3875. /** Gets or set information about font offsets (used to render and align text) */
  3876. get: function () {
  3877. return this._fontOffset;
  3878. },
  3879. set: function (offset) {
  3880. this._fontOffset = offset;
  3881. },
  3882. enumerable: false,
  3883. configurable: true
  3884. });
  3885. Object.defineProperty(Control.prototype, "alpha", {
  3886. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3887. get: function () {
  3888. return this._alpha;
  3889. },
  3890. set: function (value) {
  3891. if (this._alpha === value) {
  3892. return;
  3893. }
  3894. this._alphaSet = true;
  3895. this._alpha = value;
  3896. this._markAsDirty();
  3897. },
  3898. enumerable: false,
  3899. configurable: true
  3900. });
  3901. Object.defineProperty(Control.prototype, "isHighlighted", {
  3902. /**
  3903. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3904. */
  3905. get: function () {
  3906. return this._isHighlighted;
  3907. },
  3908. set: function (value) {
  3909. if (this._isHighlighted === value) {
  3910. return;
  3911. }
  3912. this._isHighlighted = value;
  3913. this._markAsDirty();
  3914. },
  3915. enumerable: false,
  3916. configurable: true
  3917. });
  3918. Object.defineProperty(Control.prototype, "scaleX", {
  3919. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3920. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3921. */
  3922. get: function () {
  3923. return this._scaleX;
  3924. },
  3925. set: function (value) {
  3926. if (this._scaleX === value) {
  3927. return;
  3928. }
  3929. this._scaleX = value;
  3930. this._markAsDirty();
  3931. this._markMatrixAsDirty();
  3932. },
  3933. enumerable: false,
  3934. configurable: true
  3935. });
  3936. Object.defineProperty(Control.prototype, "scaleY", {
  3937. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3938. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3939. */
  3940. get: function () {
  3941. return this._scaleY;
  3942. },
  3943. set: function (value) {
  3944. if (this._scaleY === value) {
  3945. return;
  3946. }
  3947. this._scaleY = value;
  3948. this._markAsDirty();
  3949. this._markMatrixAsDirty();
  3950. },
  3951. enumerable: false,
  3952. configurable: true
  3953. });
  3954. Object.defineProperty(Control.prototype, "rotation", {
  3955. /** Gets or sets the rotation angle (0 by default)
  3956. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3957. */
  3958. get: function () {
  3959. return this._rotation;
  3960. },
  3961. set: function (value) {
  3962. if (this._rotation === value) {
  3963. return;
  3964. }
  3965. this._rotation = value;
  3966. this._markAsDirty();
  3967. this._markMatrixAsDirty();
  3968. },
  3969. enumerable: false,
  3970. configurable: true
  3971. });
  3972. Object.defineProperty(Control.prototype, "transformCenterY", {
  3973. /** Gets or sets the transformation center on Y axis (0 by default)
  3974. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3975. */
  3976. get: function () {
  3977. return this._transformCenterY;
  3978. },
  3979. set: function (value) {
  3980. if (this._transformCenterY === value) {
  3981. return;
  3982. }
  3983. this._transformCenterY = value;
  3984. this._markAsDirty();
  3985. this._markMatrixAsDirty();
  3986. },
  3987. enumerable: false,
  3988. configurable: true
  3989. });
  3990. Object.defineProperty(Control.prototype, "transformCenterX", {
  3991. /** Gets or sets the transformation center on X axis (0 by default)
  3992. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3993. */
  3994. get: function () {
  3995. return this._transformCenterX;
  3996. },
  3997. set: function (value) {
  3998. if (this._transformCenterX === value) {
  3999. return;
  4000. }
  4001. this._transformCenterX = value;
  4002. this._markAsDirty();
  4003. this._markMatrixAsDirty();
  4004. },
  4005. enumerable: false,
  4006. configurable: true
  4007. });
  4008. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4009. /**
  4010. * Gets or sets the horizontal alignment
  4011. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4012. */
  4013. get: function () {
  4014. return this._horizontalAlignment;
  4015. },
  4016. set: function (value) {
  4017. if (this._horizontalAlignment === value) {
  4018. return;
  4019. }
  4020. this._horizontalAlignment = value;
  4021. this._markAsDirty();
  4022. },
  4023. enumerable: false,
  4024. configurable: true
  4025. });
  4026. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4027. /**
  4028. * Gets or sets the vertical alignment
  4029. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4030. */
  4031. get: function () {
  4032. return this._verticalAlignment;
  4033. },
  4034. set: function (value) {
  4035. if (this._verticalAlignment === value) {
  4036. return;
  4037. }
  4038. this._verticalAlignment = value;
  4039. this._markAsDirty();
  4040. },
  4041. enumerable: false,
  4042. configurable: true
  4043. });
  4044. Object.defineProperty(Control.prototype, "width", {
  4045. /**
  4046. * Gets or sets control width
  4047. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4048. */
  4049. get: function () {
  4050. return this._width.toString(this._host);
  4051. },
  4052. set: function (value) {
  4053. if (this._width.toString(this._host) === value) {
  4054. return;
  4055. }
  4056. if (this._width.fromString(value)) {
  4057. this._markAsDirty();
  4058. }
  4059. },
  4060. enumerable: false,
  4061. configurable: true
  4062. });
  4063. Object.defineProperty(Control.prototype, "widthInPixels", {
  4064. /**
  4065. * Gets or sets the control width in pixel
  4066. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4067. */
  4068. get: function () {
  4069. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4070. },
  4071. set: function (value) {
  4072. if (isNaN(value)) {
  4073. return;
  4074. }
  4075. this.width = value + "px";
  4076. },
  4077. enumerable: false,
  4078. configurable: true
  4079. });
  4080. Object.defineProperty(Control.prototype, "height", {
  4081. /**
  4082. * Gets or sets control height
  4083. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4084. */
  4085. get: function () {
  4086. return this._height.toString(this._host);
  4087. },
  4088. set: function (value) {
  4089. if (this._height.toString(this._host) === value) {
  4090. return;
  4091. }
  4092. if (this._height.fromString(value)) {
  4093. this._markAsDirty();
  4094. }
  4095. },
  4096. enumerable: false,
  4097. configurable: true
  4098. });
  4099. Object.defineProperty(Control.prototype, "heightInPixels", {
  4100. /**
  4101. * Gets or sets control height in pixel
  4102. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4103. */
  4104. get: function () {
  4105. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4106. },
  4107. set: function (value) {
  4108. if (isNaN(value)) {
  4109. return;
  4110. }
  4111. this.height = value + "px";
  4112. },
  4113. enumerable: false,
  4114. configurable: true
  4115. });
  4116. Object.defineProperty(Control.prototype, "fontFamily", {
  4117. /** Gets or set font family */
  4118. get: function () {
  4119. if (!this._fontSet) {
  4120. return "";
  4121. }
  4122. return this._fontFamily;
  4123. },
  4124. set: function (value) {
  4125. if (this._fontFamily === value) {
  4126. return;
  4127. }
  4128. this._fontFamily = value;
  4129. this._resetFontCache();
  4130. },
  4131. enumerable: false,
  4132. configurable: true
  4133. });
  4134. Object.defineProperty(Control.prototype, "fontStyle", {
  4135. /** Gets or sets font style */
  4136. get: function () {
  4137. return this._fontStyle;
  4138. },
  4139. set: function (value) {
  4140. if (this._fontStyle === value) {
  4141. return;
  4142. }
  4143. this._fontStyle = value;
  4144. this._resetFontCache();
  4145. },
  4146. enumerable: false,
  4147. configurable: true
  4148. });
  4149. Object.defineProperty(Control.prototype, "fontWeight", {
  4150. /** Gets or sets font weight */
  4151. get: function () {
  4152. return this._fontWeight;
  4153. },
  4154. set: function (value) {
  4155. if (this._fontWeight === value) {
  4156. return;
  4157. }
  4158. this._fontWeight = value;
  4159. this._resetFontCache();
  4160. },
  4161. enumerable: false,
  4162. configurable: true
  4163. });
  4164. Object.defineProperty(Control.prototype, "style", {
  4165. /**
  4166. * Gets or sets style
  4167. * @see https://doc.babylonjs.com/how_to/gui#styles
  4168. */
  4169. get: function () {
  4170. return this._style;
  4171. },
  4172. set: function (value) {
  4173. var _this = this;
  4174. if (this._style) {
  4175. this._style.onChangedObservable.remove(this._styleObserver);
  4176. this._styleObserver = null;
  4177. }
  4178. this._style = value;
  4179. if (this._style) {
  4180. this._styleObserver = this._style.onChangedObservable.add(function () {
  4181. _this._markAsDirty();
  4182. _this._resetFontCache();
  4183. });
  4184. }
  4185. this._markAsDirty();
  4186. this._resetFontCache();
  4187. },
  4188. enumerable: false,
  4189. configurable: true
  4190. });
  4191. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4192. /** @hidden */
  4193. get: function () {
  4194. return this._fontSize.isPercentage;
  4195. },
  4196. enumerable: false,
  4197. configurable: true
  4198. });
  4199. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4200. /** Gets or sets font size in pixels */
  4201. get: function () {
  4202. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4203. if (fontSizeToUse.isPixel) {
  4204. return fontSizeToUse.getValue(this._host);
  4205. }
  4206. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4207. },
  4208. set: function (value) {
  4209. if (isNaN(value)) {
  4210. return;
  4211. }
  4212. this.fontSize = value + "px";
  4213. },
  4214. enumerable: false,
  4215. configurable: true
  4216. });
  4217. Object.defineProperty(Control.prototype, "fontSize", {
  4218. /** Gets or sets font size */
  4219. get: function () {
  4220. return this._fontSize.toString(this._host);
  4221. },
  4222. set: function (value) {
  4223. if (this._fontSize.toString(this._host) === value) {
  4224. return;
  4225. }
  4226. if (this._fontSize.fromString(value)) {
  4227. this._markAsDirty();
  4228. this._resetFontCache();
  4229. }
  4230. },
  4231. enumerable: false,
  4232. configurable: true
  4233. });
  4234. Object.defineProperty(Control.prototype, "color", {
  4235. /** Gets or sets foreground color */
  4236. get: function () {
  4237. return this._color;
  4238. },
  4239. set: function (value) {
  4240. if (this._color === value) {
  4241. return;
  4242. }
  4243. this._color = value;
  4244. this._markAsDirty();
  4245. },
  4246. enumerable: false,
  4247. configurable: true
  4248. });
  4249. Object.defineProperty(Control.prototype, "zIndex", {
  4250. /** Gets or sets z index which is used to reorder controls on the z axis */
  4251. get: function () {
  4252. return this._zIndex;
  4253. },
  4254. set: function (value) {
  4255. if (this.zIndex === value) {
  4256. return;
  4257. }
  4258. this._zIndex = value;
  4259. if (this.parent) {
  4260. this.parent._reOrderControl(this);
  4261. }
  4262. },
  4263. enumerable: false,
  4264. configurable: true
  4265. });
  4266. Object.defineProperty(Control.prototype, "notRenderable", {
  4267. /** Gets or sets a boolean indicating if the control can be rendered */
  4268. get: function () {
  4269. return this._doNotRender;
  4270. },
  4271. set: function (value) {
  4272. if (this._doNotRender === value) {
  4273. return;
  4274. }
  4275. this._doNotRender = value;
  4276. this._markAsDirty();
  4277. },
  4278. enumerable: false,
  4279. configurable: true
  4280. });
  4281. Object.defineProperty(Control.prototype, "isVisible", {
  4282. /** Gets or sets a boolean indicating if the control is visible */
  4283. get: function () {
  4284. return this._isVisible;
  4285. },
  4286. set: function (value) {
  4287. if (this._isVisible === value) {
  4288. return;
  4289. }
  4290. this._isVisible = value;
  4291. this._markAsDirty(true);
  4292. },
  4293. enumerable: false,
  4294. configurable: true
  4295. });
  4296. Object.defineProperty(Control.prototype, "isDirty", {
  4297. /** Gets a boolean indicating that the control needs to update its rendering */
  4298. get: function () {
  4299. return this._isDirty;
  4300. },
  4301. enumerable: false,
  4302. configurable: true
  4303. });
  4304. Object.defineProperty(Control.prototype, "linkedMesh", {
  4305. /**
  4306. * Gets the current linked mesh (or null if none)
  4307. */
  4308. get: function () {
  4309. return this._linkedMesh;
  4310. },
  4311. enumerable: false,
  4312. configurable: true
  4313. });
  4314. Object.defineProperty(Control.prototype, "paddingLeft", {
  4315. /**
  4316. * Gets or sets a value indicating the padding to use on the left of the control
  4317. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4318. */
  4319. get: function () {
  4320. return this._paddingLeft.toString(this._host);
  4321. },
  4322. set: function (value) {
  4323. if (this._paddingLeft.fromString(value)) {
  4324. this._markAsDirty();
  4325. }
  4326. },
  4327. enumerable: false,
  4328. configurable: true
  4329. });
  4330. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4331. /**
  4332. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4333. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4334. */
  4335. get: function () {
  4336. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4337. },
  4338. set: function (value) {
  4339. if (isNaN(value)) {
  4340. return;
  4341. }
  4342. this.paddingLeft = value + "px";
  4343. },
  4344. enumerable: false,
  4345. configurable: true
  4346. });
  4347. Object.defineProperty(Control.prototype, "paddingRight", {
  4348. /**
  4349. * Gets or sets a value indicating the padding to use on the right of the control
  4350. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4351. */
  4352. get: function () {
  4353. return this._paddingRight.toString(this._host);
  4354. },
  4355. set: function (value) {
  4356. if (this._paddingRight.fromString(value)) {
  4357. this._markAsDirty();
  4358. }
  4359. },
  4360. enumerable: false,
  4361. configurable: true
  4362. });
  4363. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4364. /**
  4365. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4366. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4367. */
  4368. get: function () {
  4369. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4370. },
  4371. set: function (value) {
  4372. if (isNaN(value)) {
  4373. return;
  4374. }
  4375. this.paddingRight = value + "px";
  4376. },
  4377. enumerable: false,
  4378. configurable: true
  4379. });
  4380. Object.defineProperty(Control.prototype, "paddingTop", {
  4381. /**
  4382. * Gets or sets a value indicating the padding to use on the top of the control
  4383. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4384. */
  4385. get: function () {
  4386. return this._paddingTop.toString(this._host);
  4387. },
  4388. set: function (value) {
  4389. if (this._paddingTop.fromString(value)) {
  4390. this._markAsDirty();
  4391. }
  4392. },
  4393. enumerable: false,
  4394. configurable: true
  4395. });
  4396. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4397. /**
  4398. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4399. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4400. */
  4401. get: function () {
  4402. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4403. },
  4404. set: function (value) {
  4405. if (isNaN(value)) {
  4406. return;
  4407. }
  4408. this.paddingTop = value + "px";
  4409. },
  4410. enumerable: false,
  4411. configurable: true
  4412. });
  4413. Object.defineProperty(Control.prototype, "paddingBottom", {
  4414. /**
  4415. * Gets or sets a value indicating the padding to use on the bottom of the control
  4416. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4417. */
  4418. get: function () {
  4419. return this._paddingBottom.toString(this._host);
  4420. },
  4421. set: function (value) {
  4422. if (this._paddingBottom.fromString(value)) {
  4423. this._markAsDirty();
  4424. }
  4425. },
  4426. enumerable: false,
  4427. configurable: true
  4428. });
  4429. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4430. /**
  4431. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4432. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4433. */
  4434. get: function () {
  4435. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4436. },
  4437. set: function (value) {
  4438. if (isNaN(value)) {
  4439. return;
  4440. }
  4441. this.paddingBottom = value + "px";
  4442. },
  4443. enumerable: false,
  4444. configurable: true
  4445. });
  4446. Object.defineProperty(Control.prototype, "left", {
  4447. /**
  4448. * Gets or sets a value indicating the left coordinate of the control
  4449. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4450. */
  4451. get: function () {
  4452. return this._left.toString(this._host);
  4453. },
  4454. set: function (value) {
  4455. if (this._left.fromString(value)) {
  4456. this._markAsDirty();
  4457. }
  4458. },
  4459. enumerable: false,
  4460. configurable: true
  4461. });
  4462. Object.defineProperty(Control.prototype, "leftInPixels", {
  4463. /**
  4464. * Gets or sets a value indicating the left coordinate in pixels of the control
  4465. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4466. */
  4467. get: function () {
  4468. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4469. },
  4470. set: function (value) {
  4471. if (isNaN(value)) {
  4472. return;
  4473. }
  4474. this.left = value + "px";
  4475. },
  4476. enumerable: false,
  4477. configurable: true
  4478. });
  4479. Object.defineProperty(Control.prototype, "top", {
  4480. /**
  4481. * Gets or sets a value indicating the top coordinate of the control
  4482. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4483. */
  4484. get: function () {
  4485. return this._top.toString(this._host);
  4486. },
  4487. set: function (value) {
  4488. if (this._top.fromString(value)) {
  4489. this._markAsDirty();
  4490. }
  4491. },
  4492. enumerable: false,
  4493. configurable: true
  4494. });
  4495. Object.defineProperty(Control.prototype, "topInPixels", {
  4496. /**
  4497. * Gets or sets a value indicating the top coordinate in pixels of the control
  4498. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4499. */
  4500. get: function () {
  4501. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4502. },
  4503. set: function (value) {
  4504. if (isNaN(value)) {
  4505. return;
  4506. }
  4507. this.top = value + "px";
  4508. },
  4509. enumerable: false,
  4510. configurable: true
  4511. });
  4512. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4513. /**
  4514. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4515. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4516. */
  4517. get: function () {
  4518. return this._linkOffsetX.toString(this._host);
  4519. },
  4520. set: function (value) {
  4521. if (this._linkOffsetX.fromString(value)) {
  4522. this._markAsDirty();
  4523. }
  4524. },
  4525. enumerable: false,
  4526. configurable: true
  4527. });
  4528. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4529. /**
  4530. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4531. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4532. */
  4533. get: function () {
  4534. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4535. },
  4536. set: function (value) {
  4537. if (isNaN(value)) {
  4538. return;
  4539. }
  4540. this.linkOffsetX = value + "px";
  4541. },
  4542. enumerable: false,
  4543. configurable: true
  4544. });
  4545. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4546. /**
  4547. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4548. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4549. */
  4550. get: function () {
  4551. return this._linkOffsetY.toString(this._host);
  4552. },
  4553. set: function (value) {
  4554. if (this._linkOffsetY.fromString(value)) {
  4555. this._markAsDirty();
  4556. }
  4557. },
  4558. enumerable: false,
  4559. configurable: true
  4560. });
  4561. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4562. /**
  4563. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4564. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4565. */
  4566. get: function () {
  4567. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4568. },
  4569. set: function (value) {
  4570. if (isNaN(value)) {
  4571. return;
  4572. }
  4573. this.linkOffsetY = value + "px";
  4574. },
  4575. enumerable: false,
  4576. configurable: true
  4577. });
  4578. Object.defineProperty(Control.prototype, "centerX", {
  4579. /** Gets the center coordinate on X axis */
  4580. get: function () {
  4581. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4582. },
  4583. enumerable: false,
  4584. configurable: true
  4585. });
  4586. Object.defineProperty(Control.prototype, "centerY", {
  4587. /** Gets the center coordinate on Y axis */
  4588. get: function () {
  4589. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4590. },
  4591. enumerable: false,
  4592. configurable: true
  4593. });
  4594. Object.defineProperty(Control.prototype, "isEnabled", {
  4595. /** Gets or sets if control is Enabled*/
  4596. get: function () {
  4597. return this._isEnabled;
  4598. },
  4599. set: function (value) {
  4600. if (this._isEnabled === value) {
  4601. return;
  4602. }
  4603. this._isEnabled = value;
  4604. this._markAsDirty();
  4605. },
  4606. enumerable: false,
  4607. configurable: true
  4608. });
  4609. Object.defineProperty(Control.prototype, "disabledColor", {
  4610. /** Gets or sets background color of control if it's disabled*/
  4611. get: function () {
  4612. return this._disabledColor;
  4613. },
  4614. set: function (value) {
  4615. if (this._disabledColor === value) {
  4616. return;
  4617. }
  4618. this._disabledColor = value;
  4619. this._markAsDirty();
  4620. },
  4621. enumerable: false,
  4622. configurable: true
  4623. });
  4624. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4625. /** Gets or sets front color of control if it's disabled*/
  4626. get: function () {
  4627. return this._disabledColorItem;
  4628. },
  4629. set: function (value) {
  4630. if (this._disabledColorItem === value) {
  4631. return;
  4632. }
  4633. this._disabledColorItem = value;
  4634. this._markAsDirty();
  4635. },
  4636. enumerable: false,
  4637. configurable: true
  4638. });
  4639. /** @hidden */
  4640. Control.prototype._getTypeName = function () {
  4641. return "Control";
  4642. };
  4643. /**
  4644. * Gets the first ascendant in the hierarchy of the given type
  4645. * @param className defines the required type
  4646. * @returns the ascendant or null if not found
  4647. */
  4648. Control.prototype.getAscendantOfClass = function (className) {
  4649. if (!this.parent) {
  4650. return null;
  4651. }
  4652. if (this.parent.getClassName() === className) {
  4653. return this.parent;
  4654. }
  4655. return this.parent.getAscendantOfClass(className);
  4656. };
  4657. /** @hidden */
  4658. Control.prototype._resetFontCache = function () {
  4659. this._fontSet = true;
  4660. this._markAsDirty();
  4661. };
  4662. /**
  4663. * Determines if a container is an ascendant of the current control
  4664. * @param container defines the container to look for
  4665. * @returns true if the container is one of the ascendant of the control
  4666. */
  4667. Control.prototype.isAscendant = function (container) {
  4668. if (!this.parent) {
  4669. return false;
  4670. }
  4671. if (this.parent === container) {
  4672. return true;
  4673. }
  4674. return this.parent.isAscendant(container);
  4675. };
  4676. /**
  4677. * Gets coordinates in local control space
  4678. * @param globalCoordinates defines the coordinates to transform
  4679. * @returns the new coordinates in local space
  4680. */
  4681. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4682. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4683. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4684. return result;
  4685. };
  4686. /**
  4687. * Gets coordinates in local control space
  4688. * @param globalCoordinates defines the coordinates to transform
  4689. * @param result defines the target vector2 where to store the result
  4690. * @returns the current control
  4691. */
  4692. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4693. result.x = globalCoordinates.x - this._currentMeasure.left;
  4694. result.y = globalCoordinates.y - this._currentMeasure.top;
  4695. return this;
  4696. };
  4697. /**
  4698. * Gets coordinates in parent local control space
  4699. * @param globalCoordinates defines the coordinates to transform
  4700. * @returns the new coordinates in parent local space
  4701. */
  4702. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4703. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4704. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4705. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4706. return result;
  4707. };
  4708. /**
  4709. * Move the current control to a vector3 position projected onto the screen.
  4710. * @param position defines the target position
  4711. * @param scene defines the hosting scene
  4712. */
  4713. Control.prototype.moveToVector3 = function (position, scene) {
  4714. if (!this._host || this.parent !== this._host._rootContainer) {
  4715. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4716. return;
  4717. }
  4718. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4719. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4720. var globalViewport = this._host._getGlobalViewport(scene);
  4721. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4722. this._moveToProjectedPosition(projectedPosition);
  4723. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4724. this.notRenderable = true;
  4725. return;
  4726. }
  4727. this.notRenderable = false;
  4728. };
  4729. /**
  4730. * Will store all controls that have this control as ascendant in a given array
  4731. * @param results defines the array where to store the descendants
  4732. * @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
  4733. * @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
  4734. */
  4735. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4736. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4737. // Do nothing by default
  4738. };
  4739. /**
  4740. * Will return all controls that have this control as ascendant
  4741. * @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
  4742. * @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
  4743. * @return all child controls
  4744. */
  4745. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4746. var results = new Array();
  4747. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4748. return results;
  4749. };
  4750. /**
  4751. * Link current control with a target mesh
  4752. * @param mesh defines the mesh to link with
  4753. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4754. */
  4755. Control.prototype.linkWithMesh = function (mesh) {
  4756. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4757. if (mesh) {
  4758. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4759. }
  4760. return;
  4761. }
  4762. var index = this._host._linkedControls.indexOf(this);
  4763. if (index !== -1) {
  4764. this._linkedMesh = mesh;
  4765. if (!mesh) {
  4766. this._host._linkedControls.splice(index, 1);
  4767. }
  4768. return;
  4769. }
  4770. else if (!mesh) {
  4771. return;
  4772. }
  4773. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4774. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4775. this._linkedMesh = mesh;
  4776. this._host._linkedControls.push(this);
  4777. };
  4778. /** @hidden */
  4779. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4780. var oldLeft = this._left.getValue(this._host);
  4781. var oldTop = this._top.getValue(this._host);
  4782. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4783. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4784. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4785. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4786. newLeft = oldLeft;
  4787. }
  4788. if (Math.abs(newTop - oldTop) < 0.5) {
  4789. newTop = oldTop;
  4790. }
  4791. }
  4792. this.left = newLeft + "px";
  4793. this.top = newTop + "px";
  4794. this._left.ignoreAdaptiveScaling = true;
  4795. this._top.ignoreAdaptiveScaling = true;
  4796. this._markAsDirty();
  4797. };
  4798. /** @hidden */
  4799. Control.prototype._offsetLeft = function (offset) {
  4800. this._isDirty = true;
  4801. this._currentMeasure.left += offset;
  4802. };
  4803. /** @hidden */
  4804. Control.prototype._offsetTop = function (offset) {
  4805. this._isDirty = true;
  4806. this._currentMeasure.top += offset;
  4807. };
  4808. /** @hidden */
  4809. Control.prototype._markMatrixAsDirty = function () {
  4810. this._isMatrixDirty = true;
  4811. this._flagDescendantsAsMatrixDirty();
  4812. };
  4813. /** @hidden */
  4814. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4815. // No child
  4816. };
  4817. /** @hidden */
  4818. Control.prototype._intersectsRect = function (rect) {
  4819. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4820. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4821. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4822. return false;
  4823. }
  4824. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4825. return false;
  4826. }
  4827. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4828. return false;
  4829. }
  4830. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4831. return false;
  4832. }
  4833. return true;
  4834. };
  4835. /** @hidden */
  4836. Control.prototype.invalidateRect = function () {
  4837. this._transform();
  4838. if (this.host && this.host.useInvalidateRectOptimization) {
  4839. // Rotate by transform to get the measure transformed to global space
  4840. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4841. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4842. // the previous measure is used to properly clear a control that is scaled down
  4843. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4844. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4845. // Expand rect based on shadows
  4846. var shadowOffsetX = this.shadowOffsetX;
  4847. var shadowOffsetY = this.shadowOffsetY;
  4848. var shadowBlur = this.shadowBlur;
  4849. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4850. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4851. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4852. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4853. 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));
  4854. }
  4855. else {
  4856. 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));
  4857. }
  4858. }
  4859. };
  4860. /** @hidden */
  4861. Control.prototype._markAsDirty = function (force) {
  4862. if (force === void 0) { force = false; }
  4863. if (!this._isVisible && !force) {
  4864. return;
  4865. }
  4866. this._isDirty = true;
  4867. // Redraw only this rectangle
  4868. if (this._host) {
  4869. this._host.markAsDirty();
  4870. }
  4871. };
  4872. /** @hidden */
  4873. Control.prototype._markAllAsDirty = function () {
  4874. this._markAsDirty();
  4875. if (this._font) {
  4876. this._prepareFont();
  4877. }
  4878. };
  4879. /** @hidden */
  4880. Control.prototype._link = function (host) {
  4881. this._host = host;
  4882. if (this._host) {
  4883. this.uniqueId = this._host.getScene().getUniqueId();
  4884. }
  4885. };
  4886. /** @hidden */
  4887. Control.prototype._transform = function (context) {
  4888. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4889. return;
  4890. }
  4891. // postTranslate
  4892. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4893. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4894. if (context) {
  4895. context.translate(offsetX, offsetY);
  4896. // rotate
  4897. context.rotate(this._rotation);
  4898. // scale
  4899. context.scale(this._scaleX, this._scaleY);
  4900. // preTranslate
  4901. context.translate(-offsetX, -offsetY);
  4902. }
  4903. // Need to update matrices?
  4904. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4905. this._cachedOffsetX = offsetX;
  4906. this._cachedOffsetY = offsetY;
  4907. this._isMatrixDirty = false;
  4908. this._flagDescendantsAsMatrixDirty();
  4909. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4910. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4911. }
  4912. };
  4913. /** @hidden */
  4914. Control.prototype._renderHighlight = function (context) {
  4915. if (!this.isHighlighted) {
  4916. return;
  4917. }
  4918. context.save();
  4919. context.strokeStyle = "#4affff";
  4920. context.lineWidth = 2;
  4921. this._renderHighlightSpecific(context);
  4922. context.restore();
  4923. };
  4924. /** @hidden */
  4925. Control.prototype._renderHighlightSpecific = function (context) {
  4926. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4927. };
  4928. /** @hidden */
  4929. Control.prototype._applyStates = function (context) {
  4930. if (this._isFontSizeInPercentage) {
  4931. this._fontSet = true;
  4932. }
  4933. if (this._fontSet) {
  4934. this._prepareFont();
  4935. this._fontSet = false;
  4936. }
  4937. if (this._font) {
  4938. context.font = this._font;
  4939. }
  4940. if (this._color) {
  4941. context.fillStyle = this._color;
  4942. }
  4943. if (Control.AllowAlphaInheritance) {
  4944. context.globalAlpha *= this._alpha;
  4945. }
  4946. else if (this._alphaSet) {
  4947. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4948. }
  4949. };
  4950. /** @hidden */
  4951. Control.prototype._layout = function (parentMeasure, context) {
  4952. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4953. return false;
  4954. }
  4955. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4956. this.host._numLayoutCalls++;
  4957. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4958. context.save();
  4959. this._applyStates(context);
  4960. var rebuildCount = 0;
  4961. do {
  4962. this._rebuildLayout = false;
  4963. this._processMeasures(parentMeasure, context);
  4964. rebuildCount++;
  4965. } while (this._rebuildLayout && rebuildCount < 3);
  4966. if (rebuildCount >= 3) {
  4967. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4968. }
  4969. context.restore();
  4970. this.invalidateRect();
  4971. this._evaluateClippingState(parentMeasure);
  4972. }
  4973. this._wasDirty = this._isDirty;
  4974. this._isDirty = false;
  4975. return true;
  4976. };
  4977. /** @hidden */
  4978. Control.prototype._processMeasures = function (parentMeasure, context) {
  4979. this._currentMeasure.copyFrom(parentMeasure);
  4980. // Let children take some pre-measurement actions
  4981. this._preMeasure(parentMeasure, context);
  4982. this._measure();
  4983. this._computeAlignment(parentMeasure, context);
  4984. // Convert to int values
  4985. this._currentMeasure.left = this._currentMeasure.left | 0;
  4986. this._currentMeasure.top = this._currentMeasure.top | 0;
  4987. this._currentMeasure.width = this._currentMeasure.width | 0;
  4988. this._currentMeasure.height = this._currentMeasure.height | 0;
  4989. // Let children add more features
  4990. this._additionalProcessing(parentMeasure, context);
  4991. this._cachedParentMeasure.copyFrom(parentMeasure);
  4992. if (this.onDirtyObservable.hasObservers()) {
  4993. this.onDirtyObservable.notifyObservers(this);
  4994. }
  4995. };
  4996. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4997. if (this.parent && this.parent.clipChildren) {
  4998. // Early clip
  4999. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5000. this._isClipped = true;
  5001. return;
  5002. }
  5003. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5004. this._isClipped = true;
  5005. return;
  5006. }
  5007. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5008. this._isClipped = true;
  5009. return;
  5010. }
  5011. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5012. this._isClipped = true;
  5013. return;
  5014. }
  5015. }
  5016. this._isClipped = false;
  5017. };
  5018. /** @hidden */
  5019. Control.prototype._measure = function () {
  5020. // Width / Height
  5021. if (this._width.isPixel) {
  5022. this._currentMeasure.width = this._width.getValue(this._host);
  5023. }
  5024. else {
  5025. this._currentMeasure.width *= this._width.getValue(this._host);
  5026. }
  5027. if (this._height.isPixel) {
  5028. this._currentMeasure.height = this._height.getValue(this._host);
  5029. }
  5030. else {
  5031. this._currentMeasure.height *= this._height.getValue(this._host);
  5032. }
  5033. };
  5034. /** @hidden */
  5035. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5036. var width = this._currentMeasure.width;
  5037. var height = this._currentMeasure.height;
  5038. var parentWidth = parentMeasure.width;
  5039. var parentHeight = parentMeasure.height;
  5040. // Left / top
  5041. var x = 0;
  5042. var y = 0;
  5043. switch (this.horizontalAlignment) {
  5044. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5045. x = 0;
  5046. break;
  5047. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5048. x = parentWidth - width;
  5049. break;
  5050. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5051. x = (parentWidth - width) / 2;
  5052. break;
  5053. }
  5054. switch (this.verticalAlignment) {
  5055. case Control.VERTICAL_ALIGNMENT_TOP:
  5056. y = 0;
  5057. break;
  5058. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5059. y = parentHeight - height;
  5060. break;
  5061. case Control.VERTICAL_ALIGNMENT_CENTER:
  5062. y = (parentHeight - height) / 2;
  5063. break;
  5064. }
  5065. if (this._paddingLeft.isPixel) {
  5066. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5067. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5068. }
  5069. else {
  5070. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5071. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5072. }
  5073. if (this._paddingRight.isPixel) {
  5074. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5075. }
  5076. else {
  5077. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5078. }
  5079. if (this._paddingTop.isPixel) {
  5080. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5081. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5082. }
  5083. else {
  5084. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5085. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5086. }
  5087. if (this._paddingBottom.isPixel) {
  5088. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5089. }
  5090. else {
  5091. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5092. }
  5093. if (this._left.isPixel) {
  5094. this._currentMeasure.left += this._left.getValue(this._host);
  5095. }
  5096. else {
  5097. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5098. }
  5099. if (this._top.isPixel) {
  5100. this._currentMeasure.top += this._top.getValue(this._host);
  5101. }
  5102. else {
  5103. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5104. }
  5105. this._currentMeasure.left += x;
  5106. this._currentMeasure.top += y;
  5107. };
  5108. /** @hidden */
  5109. Control.prototype._preMeasure = function (parentMeasure, context) {
  5110. // Do nothing
  5111. };
  5112. /** @hidden */
  5113. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5114. // Do nothing
  5115. };
  5116. /** @hidden */
  5117. Control.prototype._clipForChildren = function (context) {
  5118. // DO nothing
  5119. };
  5120. Control.prototype._clip = function (context, invalidatedRectangle) {
  5121. context.beginPath();
  5122. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5123. if (invalidatedRectangle) {
  5124. // Rotate the invalidated rect into the control's space
  5125. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5126. // Get the intersection of the rect in context space and the current context
  5127. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5128. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5129. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5130. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5131. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5132. Control._ClipMeasure.copyFrom(intersection);
  5133. }
  5134. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5135. var shadowOffsetX = this.shadowOffsetX;
  5136. var shadowOffsetY = this.shadowOffsetY;
  5137. var shadowBlur = this.shadowBlur;
  5138. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5139. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5140. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5141. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5142. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5143. }
  5144. else {
  5145. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5146. }
  5147. context.clip();
  5148. };
  5149. /** @hidden */
  5150. Control.prototype._render = function (context, invalidatedRectangle) {
  5151. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5152. this._isDirty = false;
  5153. return false;
  5154. }
  5155. this.host._numRenderCalls++;
  5156. context.save();
  5157. this._applyStates(context);
  5158. // Transform
  5159. this._transform(context);
  5160. // Clip
  5161. if (this.clipContent) {
  5162. this._clip(context, invalidatedRectangle);
  5163. }
  5164. if (this.onBeforeDrawObservable.hasObservers()) {
  5165. this.onBeforeDrawObservable.notifyObservers(this);
  5166. }
  5167. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5168. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5169. }
  5170. else {
  5171. this._draw(context, invalidatedRectangle);
  5172. }
  5173. if (this.useBitmapCache && this._wasDirty) {
  5174. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5175. }
  5176. this._renderHighlight(context);
  5177. if (this.onAfterDrawObservable.hasObservers()) {
  5178. this.onAfterDrawObservable.notifyObservers(this);
  5179. }
  5180. context.restore();
  5181. return true;
  5182. };
  5183. /** @hidden */
  5184. Control.prototype._draw = function (context, invalidatedRectangle) {
  5185. // Do nothing
  5186. };
  5187. /**
  5188. * Tests if a given coordinates belong to the current control
  5189. * @param x defines x coordinate to test
  5190. * @param y defines y coordinate to test
  5191. * @returns true if the coordinates are inside the control
  5192. */
  5193. Control.prototype.contains = function (x, y) {
  5194. // Invert transform
  5195. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5196. x = this._transformedPosition.x;
  5197. y = this._transformedPosition.y;
  5198. // Check
  5199. if (x < this._currentMeasure.left) {
  5200. return false;
  5201. }
  5202. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5203. return false;
  5204. }
  5205. if (y < this._currentMeasure.top) {
  5206. return false;
  5207. }
  5208. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5209. return false;
  5210. }
  5211. if (this.isPointerBlocker) {
  5212. this._host._shouldBlockPointer = true;
  5213. }
  5214. return true;
  5215. };
  5216. /** @hidden */
  5217. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5218. if (!this._isEnabled) {
  5219. return false;
  5220. }
  5221. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5222. return false;
  5223. }
  5224. if (!this.contains(x, y)) {
  5225. return false;
  5226. }
  5227. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5228. return true;
  5229. };
  5230. /** @hidden */
  5231. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5232. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5233. if (canNotify && this.parent != null) {
  5234. this.parent._onPointerMove(target, coordinates, pointerId);
  5235. }
  5236. };
  5237. /** @hidden */
  5238. Control.prototype._onPointerEnter = function (target) {
  5239. if (!this._isEnabled) {
  5240. return false;
  5241. }
  5242. if (this._enterCount > 0) {
  5243. return false;
  5244. }
  5245. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5246. this._enterCount = 0;
  5247. }
  5248. this._enterCount++;
  5249. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5250. if (canNotify && this.parent != null) {
  5251. this.parent._onPointerEnter(target);
  5252. }
  5253. return true;
  5254. };
  5255. /** @hidden */
  5256. Control.prototype._onPointerOut = function (target, force) {
  5257. if (force === void 0) { force = false; }
  5258. if (!force && (!this._isEnabled || target === this)) {
  5259. return;
  5260. }
  5261. this._enterCount = 0;
  5262. var canNotify = true;
  5263. if (!target.isAscendant(this)) {
  5264. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5265. }
  5266. if (canNotify && this.parent != null) {
  5267. this.parent._onPointerOut(target, force);
  5268. }
  5269. };
  5270. /** @hidden */
  5271. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5272. // Prevent pointerout to lose control context.
  5273. // Event redundancy is checked inside the function.
  5274. this._onPointerEnter(this);
  5275. if (this._downCount !== 0) {
  5276. return false;
  5277. }
  5278. this._downCount++;
  5279. this._downPointerIds[pointerId] = true;
  5280. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5281. if (canNotify && this.parent != null) {
  5282. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5283. }
  5284. return true;
  5285. };
  5286. /** @hidden */
  5287. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5288. if (!this._isEnabled) {
  5289. return;
  5290. }
  5291. this._downCount = 0;
  5292. delete this._downPointerIds[pointerId];
  5293. var canNotifyClick = notifyClick;
  5294. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5295. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5296. }
  5297. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5298. if (canNotify && this.parent != null) {
  5299. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5300. }
  5301. };
  5302. /** @hidden */
  5303. Control.prototype._forcePointerUp = function (pointerId) {
  5304. if (pointerId === void 0) { pointerId = null; }
  5305. if (pointerId !== null) {
  5306. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5307. }
  5308. else {
  5309. for (var key in this._downPointerIds) {
  5310. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5311. }
  5312. }
  5313. };
  5314. /** @hidden */
  5315. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5316. if (!this._isEnabled) {
  5317. return;
  5318. }
  5319. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5320. if (canNotify && this.parent != null) {
  5321. this.parent._onWheelScroll(deltaX, deltaY);
  5322. }
  5323. };
  5324. /** @hidden */
  5325. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5326. if (!this._isEnabled) {
  5327. return false;
  5328. }
  5329. this._dummyVector2.copyFromFloats(x, y);
  5330. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5331. this._onPointerMove(this, this._dummyVector2, pointerId);
  5332. var previousControlOver = this._host._lastControlOver[pointerId];
  5333. if (previousControlOver && previousControlOver !== this) {
  5334. previousControlOver._onPointerOut(this);
  5335. }
  5336. if (previousControlOver !== this) {
  5337. this._onPointerEnter(this);
  5338. }
  5339. this._host._lastControlOver[pointerId] = this;
  5340. return true;
  5341. }
  5342. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5343. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5344. this._host._registerLastControlDown(this, pointerId);
  5345. this._host._lastPickedControl = this;
  5346. return true;
  5347. }
  5348. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5349. if (this._host._lastControlDown[pointerId]) {
  5350. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5351. }
  5352. delete this._host._lastControlDown[pointerId];
  5353. return true;
  5354. }
  5355. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5356. if (this._host._lastControlOver[pointerId]) {
  5357. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5358. return true;
  5359. }
  5360. }
  5361. return false;
  5362. };
  5363. Control.prototype._prepareFont = function () {
  5364. if (!this._font && !this._fontSet) {
  5365. return;
  5366. }
  5367. if (this._style) {
  5368. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5369. }
  5370. else {
  5371. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5372. }
  5373. this._fontOffset = Control._GetFontOffset(this._font);
  5374. };
  5375. /** Releases associated resources */
  5376. Control.prototype.dispose = function () {
  5377. this.onDirtyObservable.clear();
  5378. this.onBeforeDrawObservable.clear();
  5379. this.onAfterDrawObservable.clear();
  5380. this.onPointerDownObservable.clear();
  5381. this.onPointerEnterObservable.clear();
  5382. this.onPointerMoveObservable.clear();
  5383. this.onPointerOutObservable.clear();
  5384. this.onPointerUpObservable.clear();
  5385. this.onPointerClickObservable.clear();
  5386. this.onWheelObservable.clear();
  5387. if (this._styleObserver && this._style) {
  5388. this._style.onChangedObservable.remove(this._styleObserver);
  5389. this._styleObserver = null;
  5390. }
  5391. if (this.parent) {
  5392. this.parent.removeControl(this);
  5393. this.parent = null;
  5394. }
  5395. if (this._host) {
  5396. var index = this._host._linkedControls.indexOf(this);
  5397. if (index > -1) {
  5398. this.linkWithMesh(null);
  5399. }
  5400. }
  5401. // Callback
  5402. this.onDisposeObservable.notifyObservers(this);
  5403. this.onDisposeObservable.clear();
  5404. };
  5405. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5406. /** HORIZONTAL_ALIGNMENT_LEFT */
  5407. get: function () {
  5408. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5409. },
  5410. enumerable: false,
  5411. configurable: true
  5412. });
  5413. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5414. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5415. get: function () {
  5416. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5417. },
  5418. enumerable: false,
  5419. configurable: true
  5420. });
  5421. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5422. /** HORIZONTAL_ALIGNMENT_CENTER */
  5423. get: function () {
  5424. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5425. },
  5426. enumerable: false,
  5427. configurable: true
  5428. });
  5429. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5430. /** VERTICAL_ALIGNMENT_TOP */
  5431. get: function () {
  5432. return Control._VERTICAL_ALIGNMENT_TOP;
  5433. },
  5434. enumerable: false,
  5435. configurable: true
  5436. });
  5437. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5438. /** VERTICAL_ALIGNMENT_BOTTOM */
  5439. get: function () {
  5440. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5441. },
  5442. enumerable: false,
  5443. configurable: true
  5444. });
  5445. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5446. /** VERTICAL_ALIGNMENT_CENTER */
  5447. get: function () {
  5448. return Control._VERTICAL_ALIGNMENT_CENTER;
  5449. },
  5450. enumerable: false,
  5451. configurable: true
  5452. });
  5453. /** @hidden */
  5454. Control._GetFontOffset = function (font) {
  5455. if (Control._FontHeightSizes[font]) {
  5456. return Control._FontHeightSizes[font];
  5457. }
  5458. var text = document.createElement("span");
  5459. text.innerHTML = "Hg";
  5460. text.style.font = font;
  5461. var block = document.createElement("div");
  5462. block.style.display = "inline-block";
  5463. block.style.width = "1px";
  5464. block.style.height = "0px";
  5465. block.style.verticalAlign = "bottom";
  5466. var div = document.createElement("div");
  5467. div.appendChild(text);
  5468. div.appendChild(block);
  5469. document.body.appendChild(div);
  5470. var fontAscent = 0;
  5471. var fontHeight = 0;
  5472. try {
  5473. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5474. block.style.verticalAlign = "baseline";
  5475. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5476. }
  5477. finally {
  5478. document.body.removeChild(div);
  5479. }
  5480. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5481. Control._FontHeightSizes[font] = result;
  5482. return result;
  5483. };
  5484. /** @hidden */
  5485. Control.drawEllipse = function (x, y, width, height, context) {
  5486. context.translate(x, y);
  5487. context.scale(width, height);
  5488. context.beginPath();
  5489. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5490. context.closePath();
  5491. context.scale(1 / width, 1 / height);
  5492. context.translate(-x, -y);
  5493. };
  5494. /**
  5495. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5496. */
  5497. Control.AllowAlphaInheritance = false;
  5498. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5499. // Statics
  5500. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5501. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5502. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5503. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5504. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5505. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5506. Control._FontHeightSizes = {};
  5507. /**
  5508. * Creates a stack panel that can be used to render headers
  5509. * @param control defines the control to associate with the header
  5510. * @param text defines the text of the header
  5511. * @param size defines the size of the header
  5512. * @param options defines options used to configure the header
  5513. * @returns a new StackPanel
  5514. * @ignore
  5515. * @hidden
  5516. */
  5517. Control.AddHeader = function () { };
  5518. return Control;
  5519. }());
  5520. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5521. /***/ }),
  5522. /***/ "./2D/controls/displayGrid.ts":
  5523. /*!************************************!*\
  5524. !*** ./2D/controls/displayGrid.ts ***!
  5525. \************************************/
  5526. /*! exports provided: DisplayGrid */
  5527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5528. "use strict";
  5529. __webpack_require__.r(__webpack_exports__);
  5530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5531. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5532. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5533. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5534. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5535. /** Class used to render a grid */
  5536. var DisplayGrid = /** @class */ (function (_super) {
  5537. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5538. /**
  5539. * Creates a new GridDisplayRectangle
  5540. * @param name defines the control name
  5541. */
  5542. function DisplayGrid(name) {
  5543. var _this = _super.call(this, name) || this;
  5544. _this.name = name;
  5545. _this._cellWidth = 20;
  5546. _this._cellHeight = 20;
  5547. _this._minorLineTickness = 1;
  5548. _this._minorLineColor = "DarkGray";
  5549. _this._majorLineTickness = 2;
  5550. _this._majorLineColor = "White";
  5551. _this._majorLineFrequency = 5;
  5552. _this._background = "Black";
  5553. _this._displayMajorLines = true;
  5554. _this._displayMinorLines = true;
  5555. return _this;
  5556. }
  5557. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5558. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5559. get: function () {
  5560. return this._displayMinorLines;
  5561. },
  5562. set: function (value) {
  5563. if (this._displayMinorLines === value) {
  5564. return;
  5565. }
  5566. this._displayMinorLines = value;
  5567. this._markAsDirty();
  5568. },
  5569. enumerable: false,
  5570. configurable: true
  5571. });
  5572. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5573. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5574. get: function () {
  5575. return this._displayMajorLines;
  5576. },
  5577. set: function (value) {
  5578. if (this._displayMajorLines === value) {
  5579. return;
  5580. }
  5581. this._displayMajorLines = value;
  5582. this._markAsDirty();
  5583. },
  5584. enumerable: false,
  5585. configurable: true
  5586. });
  5587. Object.defineProperty(DisplayGrid.prototype, "background", {
  5588. /** Gets or sets background color (Black by default) */
  5589. get: function () {
  5590. return this._background;
  5591. },
  5592. set: function (value) {
  5593. if (this._background === value) {
  5594. return;
  5595. }
  5596. this._background = value;
  5597. this._markAsDirty();
  5598. },
  5599. enumerable: false,
  5600. configurable: true
  5601. });
  5602. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5603. /** Gets or sets the width of each cell (20 by default) */
  5604. get: function () {
  5605. return this._cellWidth;
  5606. },
  5607. set: function (value) {
  5608. this._cellWidth = value;
  5609. this._markAsDirty();
  5610. },
  5611. enumerable: false,
  5612. configurable: true
  5613. });
  5614. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5615. /** Gets or sets the height of each cell (20 by default) */
  5616. get: function () {
  5617. return this._cellHeight;
  5618. },
  5619. set: function (value) {
  5620. this._cellHeight = value;
  5621. this._markAsDirty();
  5622. },
  5623. enumerable: false,
  5624. configurable: true
  5625. });
  5626. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5627. /** Gets or sets the tickness of minor lines (1 by default) */
  5628. get: function () {
  5629. return this._minorLineTickness;
  5630. },
  5631. set: function (value) {
  5632. this._minorLineTickness = value;
  5633. this._markAsDirty();
  5634. },
  5635. enumerable: false,
  5636. configurable: true
  5637. });
  5638. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5639. /** Gets or sets the color of minor lines (DarkGray by default) */
  5640. get: function () {
  5641. return this._minorLineColor;
  5642. },
  5643. set: function (value) {
  5644. this._minorLineColor = value;
  5645. this._markAsDirty();
  5646. },
  5647. enumerable: false,
  5648. configurable: true
  5649. });
  5650. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5651. /** Gets or sets the tickness of major lines (2 by default) */
  5652. get: function () {
  5653. return this._majorLineTickness;
  5654. },
  5655. set: function (value) {
  5656. this._majorLineTickness = value;
  5657. this._markAsDirty();
  5658. },
  5659. enumerable: false,
  5660. configurable: true
  5661. });
  5662. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5663. /** Gets or sets the color of major lines (White by default) */
  5664. get: function () {
  5665. return this._majorLineColor;
  5666. },
  5667. set: function (value) {
  5668. this._majorLineColor = value;
  5669. this._markAsDirty();
  5670. },
  5671. enumerable: false,
  5672. configurable: true
  5673. });
  5674. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5675. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5676. get: function () {
  5677. return this._majorLineFrequency;
  5678. },
  5679. set: function (value) {
  5680. this._majorLineFrequency = value;
  5681. this._markAsDirty();
  5682. },
  5683. enumerable: false,
  5684. configurable: true
  5685. });
  5686. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5687. context.save();
  5688. this._applyStates(context);
  5689. if (this._isEnabled) {
  5690. if (this._background) {
  5691. context.fillStyle = this._background;
  5692. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5693. }
  5694. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5695. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5696. // Minor lines
  5697. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5698. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5699. if (this._displayMinorLines) {
  5700. context.strokeStyle = this._minorLineColor;
  5701. context.lineWidth = this._minorLineTickness;
  5702. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5703. var cellX = left + x * this.cellWidth;
  5704. context.beginPath();
  5705. context.moveTo(cellX, this._currentMeasure.top);
  5706. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5707. context.stroke();
  5708. }
  5709. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5710. var cellY = top_1 + y * this.cellHeight;
  5711. context.beginPath();
  5712. context.moveTo(this._currentMeasure.left, cellY);
  5713. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5714. context.stroke();
  5715. }
  5716. }
  5717. // Major lines
  5718. if (this._displayMajorLines) {
  5719. context.strokeStyle = this._majorLineColor;
  5720. context.lineWidth = this._majorLineTickness;
  5721. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5722. var cellX = left + x * this.cellWidth;
  5723. context.beginPath();
  5724. context.moveTo(cellX, this._currentMeasure.top);
  5725. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5726. context.stroke();
  5727. }
  5728. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5729. var cellY = top_1 + y * this.cellHeight;
  5730. context.moveTo(this._currentMeasure.left, cellY);
  5731. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5732. context.closePath();
  5733. context.stroke();
  5734. }
  5735. }
  5736. }
  5737. context.restore();
  5738. };
  5739. DisplayGrid.prototype._getTypeName = function () {
  5740. return "DisplayGrid";
  5741. };
  5742. return DisplayGrid;
  5743. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5744. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5745. /***/ }),
  5746. /***/ "./2D/controls/ellipse.ts":
  5747. /*!********************************!*\
  5748. !*** ./2D/controls/ellipse.ts ***!
  5749. \********************************/
  5750. /*! exports provided: Ellipse */
  5751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5752. "use strict";
  5753. __webpack_require__.r(__webpack_exports__);
  5754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5755. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5756. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5757. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5758. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5759. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5760. /** Class used to create 2D ellipse containers */
  5761. var Ellipse = /** @class */ (function (_super) {
  5762. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5763. /**
  5764. * Creates a new Ellipse
  5765. * @param name defines the control name
  5766. */
  5767. function Ellipse(name) {
  5768. var _this = _super.call(this, name) || this;
  5769. _this.name = name;
  5770. _this._thickness = 1;
  5771. return _this;
  5772. }
  5773. Object.defineProperty(Ellipse.prototype, "thickness", {
  5774. /** Gets or sets border thickness */
  5775. get: function () {
  5776. return this._thickness;
  5777. },
  5778. set: function (value) {
  5779. if (this._thickness === value) {
  5780. return;
  5781. }
  5782. this._thickness = value;
  5783. this._markAsDirty();
  5784. },
  5785. enumerable: false,
  5786. configurable: true
  5787. });
  5788. Ellipse.prototype._getTypeName = function () {
  5789. return "Ellipse";
  5790. };
  5791. Ellipse.prototype._localDraw = function (context) {
  5792. context.save();
  5793. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5794. context.shadowColor = this.shadowColor;
  5795. context.shadowBlur = this.shadowBlur;
  5796. context.shadowOffsetX = this.shadowOffsetX;
  5797. context.shadowOffsetY = this.shadowOffsetY;
  5798. }
  5799. _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);
  5800. if (this._background) {
  5801. context.fillStyle = this._background;
  5802. context.fill();
  5803. }
  5804. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5805. context.shadowBlur = 0;
  5806. context.shadowOffsetX = 0;
  5807. context.shadowOffsetY = 0;
  5808. }
  5809. if (this._thickness) {
  5810. if (this.color) {
  5811. context.strokeStyle = this.color;
  5812. }
  5813. context.lineWidth = this._thickness;
  5814. context.stroke();
  5815. }
  5816. context.restore();
  5817. };
  5818. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5819. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5820. this._measureForChildren.width -= 2 * this._thickness;
  5821. this._measureForChildren.height -= 2 * this._thickness;
  5822. this._measureForChildren.left += this._thickness;
  5823. this._measureForChildren.top += this._thickness;
  5824. };
  5825. Ellipse.prototype._clipForChildren = function (context) {
  5826. _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);
  5827. context.clip();
  5828. };
  5829. return Ellipse;
  5830. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5831. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5832. /***/ }),
  5833. /***/ "./2D/controls/grid.ts":
  5834. /*!*****************************!*\
  5835. !*** ./2D/controls/grid.ts ***!
  5836. \*****************************/
  5837. /*! exports provided: Grid */
  5838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5839. "use strict";
  5840. __webpack_require__.r(__webpack_exports__);
  5841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5842. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5843. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5844. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5845. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5846. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5847. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5848. /**
  5849. * Class used to create a 2D grid container
  5850. */
  5851. var Grid = /** @class */ (function (_super) {
  5852. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5853. /**
  5854. * Creates a new Grid
  5855. * @param name defines control name
  5856. */
  5857. function Grid(name) {
  5858. var _this = _super.call(this, name) || this;
  5859. _this.name = name;
  5860. _this._rowDefinitions = new Array();
  5861. _this._columnDefinitions = new Array();
  5862. _this._cells = {};
  5863. _this._childControls = new Array();
  5864. return _this;
  5865. }
  5866. Object.defineProperty(Grid.prototype, "columnCount", {
  5867. /**
  5868. * Gets the number of columns
  5869. */
  5870. get: function () {
  5871. return this._columnDefinitions.length;
  5872. },
  5873. enumerable: false,
  5874. configurable: true
  5875. });
  5876. Object.defineProperty(Grid.prototype, "rowCount", {
  5877. /**
  5878. * Gets the number of rows
  5879. */
  5880. get: function () {
  5881. return this._rowDefinitions.length;
  5882. },
  5883. enumerable: false,
  5884. configurable: true
  5885. });
  5886. Object.defineProperty(Grid.prototype, "children", {
  5887. /** Gets the list of children */
  5888. get: function () {
  5889. return this._childControls;
  5890. },
  5891. enumerable: false,
  5892. configurable: true
  5893. });
  5894. Object.defineProperty(Grid.prototype, "cells", {
  5895. /** Gets the list of cells (e.g. the containers) */
  5896. get: function () {
  5897. return this._cells;
  5898. },
  5899. enumerable: false,
  5900. configurable: true
  5901. });
  5902. /**
  5903. * Gets the definition of a specific row
  5904. * @param index defines the index of the row
  5905. * @returns the row definition
  5906. */
  5907. Grid.prototype.getRowDefinition = function (index) {
  5908. if (index < 0 || index >= this._rowDefinitions.length) {
  5909. return null;
  5910. }
  5911. return this._rowDefinitions[index];
  5912. };
  5913. /**
  5914. * Gets the definition of a specific column
  5915. * @param index defines the index of the column
  5916. * @returns the column definition
  5917. */
  5918. Grid.prototype.getColumnDefinition = function (index) {
  5919. if (index < 0 || index >= this._columnDefinitions.length) {
  5920. return null;
  5921. }
  5922. return this._columnDefinitions[index];
  5923. };
  5924. /**
  5925. * Adds a new row to the grid
  5926. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5927. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5928. * @returns the current grid
  5929. */
  5930. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5931. if (isPixel === void 0) { isPixel = false; }
  5932. 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));
  5933. this._markAsDirty();
  5934. return this;
  5935. };
  5936. /**
  5937. * Adds a new column to the grid
  5938. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5939. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5940. * @returns the current grid
  5941. */
  5942. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5943. if (isPixel === void 0) { isPixel = false; }
  5944. 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));
  5945. this._markAsDirty();
  5946. return this;
  5947. };
  5948. /**
  5949. * Update a row definition
  5950. * @param index defines the index of the row to update
  5951. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5952. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5953. * @returns the current grid
  5954. */
  5955. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5956. if (isPixel === void 0) { isPixel = false; }
  5957. if (index < 0 || index >= this._rowDefinitions.length) {
  5958. return this;
  5959. }
  5960. var current = this._rowDefinitions[index];
  5961. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5962. return this;
  5963. }
  5964. 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);
  5965. this._markAsDirty();
  5966. return this;
  5967. };
  5968. /**
  5969. * Update a column definition
  5970. * @param index defines the index of the column to update
  5971. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5972. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5973. * @returns the current grid
  5974. */
  5975. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5976. if (isPixel === void 0) { isPixel = false; }
  5977. if (index < 0 || index >= this._columnDefinitions.length) {
  5978. return this;
  5979. }
  5980. var current = this._columnDefinitions[index];
  5981. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5982. return this;
  5983. }
  5984. 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);
  5985. this._markAsDirty();
  5986. return this;
  5987. };
  5988. /**
  5989. * Gets the list of children stored in a specific cell
  5990. * @param row defines the row to check
  5991. * @param column defines the column to check
  5992. * @returns the list of controls
  5993. */
  5994. Grid.prototype.getChildrenAt = function (row, column) {
  5995. var cell = this._cells[row + ":" + column];
  5996. if (!cell) {
  5997. return null;
  5998. }
  5999. return cell.children;
  6000. };
  6001. /**
  6002. * Gets a string representing the child cell info (row x column)
  6003. * @param child defines the control to get info from
  6004. * @returns a string containing the child cell info (row x column)
  6005. */
  6006. Grid.prototype.getChildCellInfo = function (child) {
  6007. return child._tag;
  6008. };
  6009. Grid.prototype._removeCell = function (cell, key) {
  6010. if (!cell) {
  6011. return;
  6012. }
  6013. _super.prototype.removeControl.call(this, cell);
  6014. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6015. var control = _a[_i];
  6016. var childIndex = this._childControls.indexOf(control);
  6017. if (childIndex !== -1) {
  6018. this._childControls.splice(childIndex, 1);
  6019. }
  6020. }
  6021. delete this._cells[key];
  6022. };
  6023. Grid.prototype._offsetCell = function (previousKey, key) {
  6024. if (!this._cells[key]) {
  6025. return;
  6026. }
  6027. this._cells[previousKey] = this._cells[key];
  6028. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6029. var control = _a[_i];
  6030. control._tag = previousKey;
  6031. }
  6032. delete this._cells[key];
  6033. };
  6034. /**
  6035. * Remove a column definition at specified index
  6036. * @param index defines the index of the column to remove
  6037. * @returns the current grid
  6038. */
  6039. Grid.prototype.removeColumnDefinition = function (index) {
  6040. if (index < 0 || index >= this._columnDefinitions.length) {
  6041. return this;
  6042. }
  6043. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6044. var key = x + ":" + index;
  6045. var cell = this._cells[key];
  6046. this._removeCell(cell, key);
  6047. }
  6048. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6049. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6050. var previousKey = x + ":" + (y - 1);
  6051. var key = x + ":" + y;
  6052. this._offsetCell(previousKey, key);
  6053. }
  6054. }
  6055. this._columnDefinitions.splice(index, 1);
  6056. this._markAsDirty();
  6057. return this;
  6058. };
  6059. /**
  6060. * Remove a row definition at specified index
  6061. * @param index defines the index of the row to remove
  6062. * @returns the current grid
  6063. */
  6064. Grid.prototype.removeRowDefinition = function (index) {
  6065. if (index < 0 || index >= this._rowDefinitions.length) {
  6066. return this;
  6067. }
  6068. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6069. var key = index + ":" + y;
  6070. var cell = this._cells[key];
  6071. this._removeCell(cell, key);
  6072. }
  6073. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6074. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6075. var previousKey = x - 1 + ":" + y;
  6076. var key = x + ":" + y;
  6077. this._offsetCell(previousKey, key);
  6078. }
  6079. }
  6080. this._rowDefinitions.splice(index, 1);
  6081. this._markAsDirty();
  6082. return this;
  6083. };
  6084. /**
  6085. * Adds a new control to the current grid
  6086. * @param control defines the control to add
  6087. * @param row defines the row where to add the control (0 by default)
  6088. * @param column defines the column where to add the control (0 by default)
  6089. * @returns the current grid
  6090. */
  6091. Grid.prototype.addControl = function (control, row, column) {
  6092. if (row === void 0) { row = 0; }
  6093. if (column === void 0) { column = 0; }
  6094. if (this._rowDefinitions.length === 0) {
  6095. // Add default row definition
  6096. this.addRowDefinition(1, false);
  6097. }
  6098. if (this._columnDefinitions.length === 0) {
  6099. // Add default column definition
  6100. this.addColumnDefinition(1, false);
  6101. }
  6102. if (this._childControls.indexOf(control) !== -1) {
  6103. 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");
  6104. return this;
  6105. }
  6106. var x = Math.min(row, this._rowDefinitions.length - 1);
  6107. var y = Math.min(column, this._columnDefinitions.length - 1);
  6108. var key = x + ":" + y;
  6109. var goodContainer = this._cells[key];
  6110. if (!goodContainer) {
  6111. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6112. this._cells[key] = goodContainer;
  6113. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6114. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6115. _super.prototype.addControl.call(this, goodContainer);
  6116. }
  6117. goodContainer.addControl(control);
  6118. this._childControls.push(control);
  6119. control._tag = key;
  6120. control.parent = this;
  6121. this._markAsDirty();
  6122. return this;
  6123. };
  6124. /**
  6125. * Removes a control from the current container
  6126. * @param control defines the control to remove
  6127. * @returns the current container
  6128. */
  6129. Grid.prototype.removeControl = function (control) {
  6130. var index = this._childControls.indexOf(control);
  6131. if (index !== -1) {
  6132. this._childControls.splice(index, 1);
  6133. }
  6134. var cell = this._cells[control._tag];
  6135. if (cell) {
  6136. cell.removeControl(control);
  6137. control._tag = null;
  6138. }
  6139. this._markAsDirty();
  6140. return this;
  6141. };
  6142. Grid.prototype._getTypeName = function () {
  6143. return "Grid";
  6144. };
  6145. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6146. var widths = [];
  6147. var heights = [];
  6148. var lefts = [];
  6149. var tops = [];
  6150. var availableWidth = this._currentMeasure.width;
  6151. var globalWidthPercentage = 0;
  6152. var availableHeight = this._currentMeasure.height;
  6153. var globalHeightPercentage = 0;
  6154. // Heights
  6155. var index = 0;
  6156. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6157. var value = _a[_i];
  6158. if (value.isPixel) {
  6159. var height = value.getValue(this._host);
  6160. availableHeight -= height;
  6161. heights[index] = height;
  6162. }
  6163. else {
  6164. globalHeightPercentage += value.internalValue;
  6165. }
  6166. index++;
  6167. }
  6168. var top = 0;
  6169. index = 0;
  6170. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6171. var value = _c[_b];
  6172. tops.push(top);
  6173. if (!value.isPixel) {
  6174. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6175. top += height;
  6176. heights[index] = height;
  6177. }
  6178. else {
  6179. top += value.getValue(this._host);
  6180. }
  6181. index++;
  6182. }
  6183. // Widths
  6184. index = 0;
  6185. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6186. var value = _e[_d];
  6187. if (value.isPixel) {
  6188. var width = value.getValue(this._host);
  6189. availableWidth -= width;
  6190. widths[index] = width;
  6191. }
  6192. else {
  6193. globalWidthPercentage += value.internalValue;
  6194. }
  6195. index++;
  6196. }
  6197. var left = 0;
  6198. index = 0;
  6199. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6200. var value = _g[_f];
  6201. lefts.push(left);
  6202. if (!value.isPixel) {
  6203. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6204. left += width;
  6205. widths[index] = width;
  6206. }
  6207. else {
  6208. left += value.getValue(this._host);
  6209. }
  6210. index++;
  6211. }
  6212. definitionCallback(lefts, tops, widths, heights);
  6213. };
  6214. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6215. var _this = this;
  6216. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6217. // Setting child sizes
  6218. for (var key in _this._cells) {
  6219. if (!_this._cells.hasOwnProperty(key)) {
  6220. continue;
  6221. }
  6222. var split = key.split(":");
  6223. var x = parseInt(split[0]);
  6224. var y = parseInt(split[1]);
  6225. var cell = _this._cells[key];
  6226. cell.left = lefts[y] + "px";
  6227. cell.top = tops[x] + "px";
  6228. cell.width = widths[y] + "px";
  6229. cell.height = heights[x] + "px";
  6230. cell._left.ignoreAdaptiveScaling = true;
  6231. cell._top.ignoreAdaptiveScaling = true;
  6232. cell._width.ignoreAdaptiveScaling = true;
  6233. cell._height.ignoreAdaptiveScaling = true;
  6234. }
  6235. });
  6236. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6237. };
  6238. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6239. for (var key in this._cells) {
  6240. if (!this._cells.hasOwnProperty(key)) {
  6241. continue;
  6242. }
  6243. var child = this._cells[key];
  6244. child._markMatrixAsDirty();
  6245. }
  6246. };
  6247. Grid.prototype._renderHighlightSpecific = function (context) {
  6248. var _this = this;
  6249. _super.prototype._renderHighlightSpecific.call(this, context);
  6250. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6251. // Columns
  6252. for (var index = 0; index < lefts.length; index++) {
  6253. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6254. context.beginPath();
  6255. context.moveTo(left, _this._currentMeasure.top);
  6256. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6257. context.stroke();
  6258. }
  6259. // Rows
  6260. for (var index = 0; index < tops.length; index++) {
  6261. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6262. context.beginPath();
  6263. context.moveTo(_this._currentMeasure.left, top_1);
  6264. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6265. context.stroke();
  6266. }
  6267. });
  6268. context.restore();
  6269. };
  6270. /** Releases associated resources */
  6271. Grid.prototype.dispose = function () {
  6272. _super.prototype.dispose.call(this);
  6273. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6274. var control = _a[_i];
  6275. control.dispose();
  6276. }
  6277. this._childControls = [];
  6278. };
  6279. return Grid;
  6280. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6281. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6282. /***/ }),
  6283. /***/ "./2D/controls/image.ts":
  6284. /*!******************************!*\
  6285. !*** ./2D/controls/image.ts ***!
  6286. \******************************/
  6287. /*! exports provided: Image */
  6288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6289. "use strict";
  6290. __webpack_require__.r(__webpack_exports__);
  6291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6293. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6294. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6295. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6296. /**
  6297. * Class used to create 2D images
  6298. */
  6299. var Image = /** @class */ (function (_super) {
  6300. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6301. /**
  6302. * Creates a new Image
  6303. * @param name defines the control name
  6304. * @param url defines the image url
  6305. */
  6306. function Image(name, url) {
  6307. if (url === void 0) { url = null; }
  6308. var _this = _super.call(this, name) || this;
  6309. _this.name = name;
  6310. _this._workingCanvas = null;
  6311. _this._loaded = false;
  6312. _this._stretch = Image.STRETCH_FILL;
  6313. _this._autoScale = false;
  6314. _this._sourceLeft = 0;
  6315. _this._sourceTop = 0;
  6316. _this._sourceWidth = 0;
  6317. _this._sourceHeight = 0;
  6318. _this._svgAttributesComputationCompleted = false;
  6319. _this._isSVG = false;
  6320. _this._cellWidth = 0;
  6321. _this._cellHeight = 0;
  6322. _this._cellId = -1;
  6323. _this._populateNinePatchSlicesFromImage = false;
  6324. /**
  6325. * Observable notified when the content is loaded
  6326. */
  6327. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6328. /**
  6329. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6330. */
  6331. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6332. _this.source = url;
  6333. return _this;
  6334. }
  6335. Object.defineProperty(Image.prototype, "isLoaded", {
  6336. /**
  6337. * Gets a boolean indicating that the content is loaded
  6338. */
  6339. get: function () {
  6340. return this._loaded;
  6341. },
  6342. enumerable: false,
  6343. configurable: true
  6344. });
  6345. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6346. /**
  6347. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6348. */
  6349. get: function () {
  6350. return this._populateNinePatchSlicesFromImage;
  6351. },
  6352. set: function (value) {
  6353. if (this._populateNinePatchSlicesFromImage === value) {
  6354. return;
  6355. }
  6356. this._populateNinePatchSlicesFromImage = value;
  6357. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6358. this._extractNinePatchSliceDataFromImage();
  6359. }
  6360. },
  6361. enumerable: false,
  6362. configurable: true
  6363. });
  6364. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6365. /**
  6366. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6367. * Beware using this as this will comsume more memory as the image has to be stored twice
  6368. */
  6369. get: function () {
  6370. return this._detectPointerOnOpaqueOnly;
  6371. },
  6372. set: function (value) {
  6373. if (this._detectPointerOnOpaqueOnly === value) {
  6374. return;
  6375. }
  6376. this._detectPointerOnOpaqueOnly = value;
  6377. },
  6378. enumerable: false,
  6379. configurable: true
  6380. });
  6381. Object.defineProperty(Image.prototype, "sliceLeft", {
  6382. /**
  6383. * Gets or sets the left value for slicing (9-patch)
  6384. */
  6385. get: function () {
  6386. return this._sliceLeft;
  6387. },
  6388. set: function (value) {
  6389. if (this._sliceLeft === value) {
  6390. return;
  6391. }
  6392. this._sliceLeft = value;
  6393. this._markAsDirty();
  6394. },
  6395. enumerable: false,
  6396. configurable: true
  6397. });
  6398. Object.defineProperty(Image.prototype, "sliceRight", {
  6399. /**
  6400. * Gets or sets the right value for slicing (9-patch)
  6401. */
  6402. get: function () {
  6403. return this._sliceRight;
  6404. },
  6405. set: function (value) {
  6406. if (this._sliceRight === value) {
  6407. return;
  6408. }
  6409. this._sliceRight = value;
  6410. this._markAsDirty();
  6411. },
  6412. enumerable: false,
  6413. configurable: true
  6414. });
  6415. Object.defineProperty(Image.prototype, "sliceTop", {
  6416. /**
  6417. * Gets or sets the top value for slicing (9-patch)
  6418. */
  6419. get: function () {
  6420. return this._sliceTop;
  6421. },
  6422. set: function (value) {
  6423. if (this._sliceTop === value) {
  6424. return;
  6425. }
  6426. this._sliceTop = value;
  6427. this._markAsDirty();
  6428. },
  6429. enumerable: false,
  6430. configurable: true
  6431. });
  6432. Object.defineProperty(Image.prototype, "sliceBottom", {
  6433. /**
  6434. * Gets or sets the bottom value for slicing (9-patch)
  6435. */
  6436. get: function () {
  6437. return this._sliceBottom;
  6438. },
  6439. set: function (value) {
  6440. if (this._sliceBottom === value) {
  6441. return;
  6442. }
  6443. this._sliceBottom = value;
  6444. this._markAsDirty();
  6445. },
  6446. enumerable: false,
  6447. configurable: true
  6448. });
  6449. Object.defineProperty(Image.prototype, "sourceLeft", {
  6450. /**
  6451. * Gets or sets the left coordinate in the source image
  6452. */
  6453. get: function () {
  6454. return this._sourceLeft;
  6455. },
  6456. set: function (value) {
  6457. if (this._sourceLeft === value) {
  6458. return;
  6459. }
  6460. this._sourceLeft = value;
  6461. this._markAsDirty();
  6462. },
  6463. enumerable: false,
  6464. configurable: true
  6465. });
  6466. Object.defineProperty(Image.prototype, "sourceTop", {
  6467. /**
  6468. * Gets or sets the top coordinate in the source image
  6469. */
  6470. get: function () {
  6471. return this._sourceTop;
  6472. },
  6473. set: function (value) {
  6474. if (this._sourceTop === value) {
  6475. return;
  6476. }
  6477. this._sourceTop = value;
  6478. this._markAsDirty();
  6479. },
  6480. enumerable: false,
  6481. configurable: true
  6482. });
  6483. Object.defineProperty(Image.prototype, "sourceWidth", {
  6484. /**
  6485. * Gets or sets the width to capture in the source image
  6486. */
  6487. get: function () {
  6488. return this._sourceWidth;
  6489. },
  6490. set: function (value) {
  6491. if (this._sourceWidth === value) {
  6492. return;
  6493. }
  6494. this._sourceWidth = value;
  6495. this._markAsDirty();
  6496. },
  6497. enumerable: false,
  6498. configurable: true
  6499. });
  6500. Object.defineProperty(Image.prototype, "sourceHeight", {
  6501. /**
  6502. * Gets or sets the height to capture in the source image
  6503. */
  6504. get: function () {
  6505. return this._sourceHeight;
  6506. },
  6507. set: function (value) {
  6508. if (this._sourceHeight === value) {
  6509. return;
  6510. }
  6511. this._sourceHeight = value;
  6512. this._markAsDirty();
  6513. },
  6514. enumerable: false,
  6515. configurable: true
  6516. });
  6517. Object.defineProperty(Image.prototype, "isSVG", {
  6518. /** Indicates if the format of the image is SVG */
  6519. get: function () {
  6520. return this._isSVG;
  6521. },
  6522. enumerable: false,
  6523. configurable: true
  6524. });
  6525. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6526. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6527. get: function () {
  6528. return this._svgAttributesComputationCompleted;
  6529. },
  6530. enumerable: false,
  6531. configurable: true
  6532. });
  6533. Object.defineProperty(Image.prototype, "autoScale", {
  6534. /**
  6535. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6536. * @see https://doc.babylonjs.com/how_to/gui#image
  6537. */
  6538. get: function () {
  6539. return this._autoScale;
  6540. },
  6541. set: function (value) {
  6542. if (this._autoScale === value) {
  6543. return;
  6544. }
  6545. this._autoScale = value;
  6546. if (value && this._loaded) {
  6547. this.synchronizeSizeWithContent();
  6548. }
  6549. },
  6550. enumerable: false,
  6551. configurable: true
  6552. });
  6553. Object.defineProperty(Image.prototype, "stretch", {
  6554. /** Gets or sets the streching mode used by the image */
  6555. get: function () {
  6556. return this._stretch;
  6557. },
  6558. set: function (value) {
  6559. if (this._stretch === value) {
  6560. return;
  6561. }
  6562. this._stretch = value;
  6563. this._markAsDirty();
  6564. },
  6565. enumerable: false,
  6566. configurable: true
  6567. });
  6568. /** @hidden */
  6569. Image.prototype._rotate90 = function (n, preserveProperties) {
  6570. if (preserveProperties === void 0) { preserveProperties = false; }
  6571. var canvas = document.createElement('canvas');
  6572. var context = canvas.getContext('2d');
  6573. var width = this._domImage.width;
  6574. var height = this._domImage.height;
  6575. canvas.width = height;
  6576. canvas.height = width;
  6577. context.translate(canvas.width / 2, canvas.height / 2);
  6578. context.rotate(n * Math.PI / 2);
  6579. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6580. var dataUrl = canvas.toDataURL("image/jpg");
  6581. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6582. if (preserveProperties) {
  6583. rotatedImage._stretch = this._stretch;
  6584. rotatedImage._autoScale = this._autoScale;
  6585. rotatedImage._cellId = this._cellId;
  6586. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6587. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6588. }
  6589. this._handleRotationForSVGImage(this, rotatedImage, n);
  6590. return rotatedImage;
  6591. };
  6592. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6593. var _this = this;
  6594. if (!srcImage._isSVG) {
  6595. return;
  6596. }
  6597. if (srcImage._svgAttributesComputationCompleted) {
  6598. this._rotate90SourceProperties(srcImage, dstImage, n);
  6599. this._markAsDirty();
  6600. }
  6601. else {
  6602. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6603. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6604. _this._markAsDirty();
  6605. });
  6606. }
  6607. };
  6608. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6609. var _a, _b;
  6610. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6611. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6612. if (n != 0) {
  6613. var mult = n < 0 ? -1 : 1;
  6614. n = n % 4;
  6615. for (var i = 0; i < Math.abs(n); ++i) {
  6616. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6617. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6618. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6619. if (n < 0) {
  6620. dstTop -= dstHeight;
  6621. }
  6622. else {
  6623. dstLeft -= dstWidth;
  6624. }
  6625. srcLeft = dstLeft;
  6626. srcTop = dstTop;
  6627. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6628. }
  6629. }
  6630. dstImage.sourceLeft = dstLeft;
  6631. dstImage.sourceTop = dstTop;
  6632. dstImage.sourceWidth = dstWidth;
  6633. dstImage.sourceHeight = dstHeight;
  6634. };
  6635. Object.defineProperty(Image.prototype, "domImage", {
  6636. get: function () {
  6637. return this._domImage;
  6638. },
  6639. /**
  6640. * Gets or sets the internal DOM image used to render the control
  6641. */
  6642. set: function (value) {
  6643. var _this = this;
  6644. this._domImage = value;
  6645. this._loaded = false;
  6646. if (this._domImage.width) {
  6647. this._onImageLoaded();
  6648. }
  6649. else {
  6650. this._domImage.onload = function () {
  6651. _this._onImageLoaded();
  6652. };
  6653. }
  6654. },
  6655. enumerable: false,
  6656. configurable: true
  6657. });
  6658. Image.prototype._onImageLoaded = function () {
  6659. this._imageWidth = this._domImage.width;
  6660. this._imageHeight = this._domImage.height;
  6661. this._loaded = true;
  6662. if (this._populateNinePatchSlicesFromImage) {
  6663. this._extractNinePatchSliceDataFromImage();
  6664. }
  6665. if (this._autoScale) {
  6666. this.synchronizeSizeWithContent();
  6667. }
  6668. this.onImageLoadedObservable.notifyObservers(this);
  6669. this._markAsDirty();
  6670. };
  6671. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6672. if (!this._workingCanvas) {
  6673. this._workingCanvas = document.createElement('canvas');
  6674. }
  6675. var canvas = this._workingCanvas;
  6676. var context = canvas.getContext('2d');
  6677. var width = this._domImage.width;
  6678. var height = this._domImage.height;
  6679. canvas.width = width;
  6680. canvas.height = height;
  6681. context.drawImage(this._domImage, 0, 0, width, height);
  6682. var imageData = context.getImageData(0, 0, width, height);
  6683. // Left and right
  6684. this._sliceLeft = -1;
  6685. this._sliceRight = -1;
  6686. for (var x = 0; x < width; x++) {
  6687. var alpha = imageData.data[x * 4 + 3];
  6688. if (alpha > 127 && this._sliceLeft === -1) {
  6689. this._sliceLeft = x;
  6690. continue;
  6691. }
  6692. if (alpha < 127 && this._sliceLeft > -1) {
  6693. this._sliceRight = x;
  6694. break;
  6695. }
  6696. }
  6697. // top and bottom
  6698. this._sliceTop = -1;
  6699. this._sliceBottom = -1;
  6700. for (var y = 0; y < height; y++) {
  6701. var alpha = imageData.data[y * width * 4 + 3];
  6702. if (alpha > 127 && this._sliceTop === -1) {
  6703. this._sliceTop = y;
  6704. continue;
  6705. }
  6706. if (alpha < 127 && this._sliceTop > -1) {
  6707. this._sliceBottom = y;
  6708. break;
  6709. }
  6710. }
  6711. };
  6712. Object.defineProperty(Image.prototype, "source", {
  6713. /**
  6714. * Gets or sets image source url
  6715. */
  6716. set: function (value) {
  6717. var _this = this;
  6718. if (this._source === value) {
  6719. return;
  6720. }
  6721. this._loaded = false;
  6722. this._source = value;
  6723. if (value) {
  6724. value = this._svgCheck(value);
  6725. }
  6726. this._domImage = document.createElement("img");
  6727. this._domImage.onload = function () {
  6728. _this._onImageLoaded();
  6729. };
  6730. if (value) {
  6731. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6732. this._domImage.src = value;
  6733. }
  6734. },
  6735. enumerable: false,
  6736. configurable: true
  6737. });
  6738. /**
  6739. * Checks for svg document with icon id present
  6740. */
  6741. Image.prototype._svgCheck = function (value) {
  6742. var _this = this;
  6743. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6744. this._isSVG = true;
  6745. var svgsrc = value.split('#')[0];
  6746. var elemid = value.split('#')[1];
  6747. // check if object alr exist in document
  6748. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6749. if (svgExist) {
  6750. var svgDoc = svgExist.contentDocument;
  6751. // get viewbox width and height, get svg document width and height in px
  6752. if (svgDoc && svgDoc.documentElement) {
  6753. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6754. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6755. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6756. var elem = svgDoc.getElementById(elemid);
  6757. if (elem && vb && docwidth && docheight) {
  6758. this._getSVGAttribs(svgExist, elemid);
  6759. return value;
  6760. }
  6761. }
  6762. // wait for object to load
  6763. svgExist.addEventListener("load", function () {
  6764. _this._getSVGAttribs(svgExist, elemid);
  6765. });
  6766. }
  6767. else {
  6768. // create document object
  6769. var svgImage = document.createElement("object");
  6770. svgImage.data = svgsrc;
  6771. svgImage.type = "image/svg+xml";
  6772. svgImage.width = "0%";
  6773. svgImage.height = "0%";
  6774. document.body.appendChild(svgImage);
  6775. // when the object has loaded, get the element attribs
  6776. svgImage.onload = function () {
  6777. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6778. if (svgobj) {
  6779. _this._getSVGAttribs(svgobj, elemid);
  6780. }
  6781. };
  6782. }
  6783. return svgsrc;
  6784. }
  6785. else {
  6786. return value;
  6787. }
  6788. };
  6789. /**
  6790. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6791. * given external svg file and icon id
  6792. */
  6793. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6794. var svgDoc = svgsrc.contentDocument;
  6795. // get viewbox width and height, get svg document width and height in px
  6796. if (svgDoc && svgDoc.documentElement) {
  6797. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6798. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6799. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6800. // get element bbox and matrix transform
  6801. var elem = svgDoc.getElementById(elemid);
  6802. if (vb && docwidth && docheight && elem) {
  6803. var vb_width = Number(vb.split(" ")[2]);
  6804. var vb_height = Number(vb.split(" ")[3]);
  6805. var elem_bbox = elem.getBBox();
  6806. var elem_matrix_a = 1;
  6807. var elem_matrix_d = 1;
  6808. var elem_matrix_e = 0;
  6809. var elem_matrix_f = 0;
  6810. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6811. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6812. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6813. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6814. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6815. }
  6816. // compute source coordinates and dimensions
  6817. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6818. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6819. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6820. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6821. this._svgAttributesComputationCompleted = true;
  6822. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6823. }
  6824. }
  6825. };
  6826. Object.defineProperty(Image.prototype, "cellWidth", {
  6827. /**
  6828. * Gets or sets the cell width to use when animation sheet is enabled
  6829. * @see https://doc.babylonjs.com/how_to/gui#image
  6830. */
  6831. get: function () {
  6832. return this._cellWidth;
  6833. },
  6834. set: function (value) {
  6835. if (this._cellWidth === value) {
  6836. return;
  6837. }
  6838. this._cellWidth = value;
  6839. this._markAsDirty();
  6840. },
  6841. enumerable: false,
  6842. configurable: true
  6843. });
  6844. Object.defineProperty(Image.prototype, "cellHeight", {
  6845. /**
  6846. * Gets or sets the cell height to use when animation sheet is enabled
  6847. * @see https://doc.babylonjs.com/how_to/gui#image
  6848. */
  6849. get: function () {
  6850. return this._cellHeight;
  6851. },
  6852. set: function (value) {
  6853. if (this._cellHeight === value) {
  6854. return;
  6855. }
  6856. this._cellHeight = value;
  6857. this._markAsDirty();
  6858. },
  6859. enumerable: false,
  6860. configurable: true
  6861. });
  6862. Object.defineProperty(Image.prototype, "cellId", {
  6863. /**
  6864. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6865. * @see https://doc.babylonjs.com/how_to/gui#image
  6866. */
  6867. get: function () {
  6868. return this._cellId;
  6869. },
  6870. set: function (value) {
  6871. if (this._cellId === value) {
  6872. return;
  6873. }
  6874. this._cellId = value;
  6875. this._markAsDirty();
  6876. },
  6877. enumerable: false,
  6878. configurable: true
  6879. });
  6880. /**
  6881. * Tests if a given coordinates belong to the current control
  6882. * @param x defines x coordinate to test
  6883. * @param y defines y coordinate to test
  6884. * @returns true if the coordinates are inside the control
  6885. */
  6886. Image.prototype.contains = function (x, y) {
  6887. if (!_super.prototype.contains.call(this, x, y)) {
  6888. return false;
  6889. }
  6890. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6891. return true;
  6892. }
  6893. var canvas = this._workingCanvas;
  6894. var context = canvas.getContext("2d");
  6895. var width = this._currentMeasure.width | 0;
  6896. var height = this._currentMeasure.height | 0;
  6897. var imageData = context.getImageData(0, 0, width, height).data;
  6898. x = (x - this._currentMeasure.left) | 0;
  6899. y = (y - this._currentMeasure.top) | 0;
  6900. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6901. return pickedPixel > 0;
  6902. };
  6903. Image.prototype._getTypeName = function () {
  6904. return "Image";
  6905. };
  6906. /** Force the control to synchronize with its content */
  6907. Image.prototype.synchronizeSizeWithContent = function () {
  6908. if (!this._loaded) {
  6909. return;
  6910. }
  6911. this.width = this._domImage.width + "px";
  6912. this.height = this._domImage.height + "px";
  6913. };
  6914. Image.prototype._processMeasures = function (parentMeasure, context) {
  6915. if (this._loaded) {
  6916. switch (this._stretch) {
  6917. case Image.STRETCH_NONE:
  6918. break;
  6919. case Image.STRETCH_FILL:
  6920. break;
  6921. case Image.STRETCH_UNIFORM:
  6922. break;
  6923. case Image.STRETCH_NINE_PATCH:
  6924. break;
  6925. case Image.STRETCH_EXTEND:
  6926. if (this._autoScale) {
  6927. this.synchronizeSizeWithContent();
  6928. }
  6929. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6930. this.parent.adaptWidthToChildren = true;
  6931. this.parent.adaptHeightToChildren = true;
  6932. }
  6933. break;
  6934. }
  6935. }
  6936. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6937. };
  6938. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6939. if (!this._detectPointerOnOpaqueOnly) {
  6940. return;
  6941. }
  6942. if (!this._workingCanvas) {
  6943. this._workingCanvas = document.createElement('canvas');
  6944. }
  6945. var canvas = this._workingCanvas;
  6946. var width = this._currentMeasure.width;
  6947. var height = this._currentMeasure.height;
  6948. var context = canvas.getContext("2d");
  6949. canvas.width = width;
  6950. canvas.height = height;
  6951. context.clearRect(0, 0, width, height);
  6952. };
  6953. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6954. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6955. if (!this._detectPointerOnOpaqueOnly) {
  6956. return;
  6957. }
  6958. var canvas = this._workingCanvas;
  6959. context = canvas.getContext("2d");
  6960. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6961. };
  6962. Image.prototype._draw = function (context) {
  6963. context.save();
  6964. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6965. context.shadowColor = this.shadowColor;
  6966. context.shadowBlur = this.shadowBlur;
  6967. context.shadowOffsetX = this.shadowOffsetX;
  6968. context.shadowOffsetY = this.shadowOffsetY;
  6969. }
  6970. var x, y, width, height;
  6971. if (this.cellId == -1) {
  6972. x = this._sourceLeft;
  6973. y = this._sourceTop;
  6974. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6975. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6976. }
  6977. else {
  6978. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6979. var column = (this.cellId / rowCount) >> 0;
  6980. var row = this.cellId % rowCount;
  6981. x = this.cellWidth * row;
  6982. y = this.cellHeight * column;
  6983. width = this.cellWidth;
  6984. height = this.cellHeight;
  6985. }
  6986. this._prepareWorkingCanvasForOpaqueDetection();
  6987. this._applyStates(context);
  6988. if (this._loaded) {
  6989. switch (this._stretch) {
  6990. case Image.STRETCH_NONE:
  6991. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6992. break;
  6993. case Image.STRETCH_FILL:
  6994. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6995. break;
  6996. case Image.STRETCH_UNIFORM:
  6997. var hRatio = this._currentMeasure.width / width;
  6998. var vRatio = this._currentMeasure.height / height;
  6999. var ratio = Math.min(hRatio, vRatio);
  7000. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7001. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7002. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7003. break;
  7004. case Image.STRETCH_EXTEND:
  7005. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7006. break;
  7007. case Image.STRETCH_NINE_PATCH:
  7008. this._renderNinePatch(context);
  7009. break;
  7010. }
  7011. }
  7012. context.restore();
  7013. };
  7014. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7015. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7016. };
  7017. Image.prototype._renderNinePatch = function (context) {
  7018. var height = this._imageHeight;
  7019. var leftWidth = this._sliceLeft;
  7020. var topHeight = this._sliceTop;
  7021. var bottomHeight = this._imageHeight - this._sliceBottom;
  7022. var rightWidth = this._imageWidth - this._sliceRight;
  7023. var left = 0;
  7024. var top = 0;
  7025. if (this._populateNinePatchSlicesFromImage) {
  7026. left = 1;
  7027. top = 1;
  7028. height -= 2;
  7029. leftWidth -= 1;
  7030. topHeight -= 1;
  7031. bottomHeight -= 1;
  7032. rightWidth -= 1;
  7033. }
  7034. var centerWidth = this._sliceRight - this._sliceLeft;
  7035. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7036. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7037. // Corners
  7038. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7039. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7040. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7041. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7042. // Center
  7043. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7044. // Borders
  7045. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7046. 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);
  7047. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7048. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7049. };
  7050. Image.prototype.dispose = function () {
  7051. _super.prototype.dispose.call(this);
  7052. this.onImageLoadedObservable.clear();
  7053. this.onSVGAttributesComputedObservable.clear();
  7054. };
  7055. // Static
  7056. /** STRETCH_NONE */
  7057. Image.STRETCH_NONE = 0;
  7058. /** STRETCH_FILL */
  7059. Image.STRETCH_FILL = 1;
  7060. /** STRETCH_UNIFORM */
  7061. Image.STRETCH_UNIFORM = 2;
  7062. /** STRETCH_EXTEND */
  7063. Image.STRETCH_EXTEND = 3;
  7064. /** NINE_PATCH */
  7065. Image.STRETCH_NINE_PATCH = 4;
  7066. return Image;
  7067. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7068. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7069. /***/ }),
  7070. /***/ "./2D/controls/index.ts":
  7071. /*!******************************!*\
  7072. !*** ./2D/controls/index.ts ***!
  7073. \******************************/
  7074. /*! 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 */
  7075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7076. "use strict";
  7077. __webpack_require__.r(__webpack_exports__);
  7078. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7080. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7082. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7084. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7086. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7088. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7090. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7092. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7094. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7096. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7098. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7100. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7102. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7104. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7106. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7112. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7114. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7117. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7120. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7122. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7124. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7126. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7128. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7130. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7132. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7134. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7136. /***/ }),
  7137. /***/ "./2D/controls/inputPassword.ts":
  7138. /*!**************************************!*\
  7139. !*** ./2D/controls/inputPassword.ts ***!
  7140. \**************************************/
  7141. /*! exports provided: InputPassword */
  7142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7143. "use strict";
  7144. __webpack_require__.r(__webpack_exports__);
  7145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7147. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7148. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  7149. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7150. /**
  7151. * Class used to create a password control
  7152. */
  7153. var InputPassword = /** @class */ (function (_super) {
  7154. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7155. function InputPassword() {
  7156. return _super !== null && _super.apply(this, arguments) || this;
  7157. }
  7158. InputPassword.prototype._beforeRenderText = function (text) {
  7159. var txt = "";
  7160. for (var i = 0; i < text.length; i++) {
  7161. txt += "\u2022";
  7162. }
  7163. return txt;
  7164. };
  7165. return InputPassword;
  7166. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7167. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7168. /***/ }),
  7169. /***/ "./2D/controls/inputText.ts":
  7170. /*!**********************************!*\
  7171. !*** ./2D/controls/inputText.ts ***!
  7172. \**********************************/
  7173. /*! exports provided: InputText */
  7174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7175. "use strict";
  7176. __webpack_require__.r(__webpack_exports__);
  7177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7179. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7180. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7181. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7182. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7183. /**
  7184. * Class used to create input text control
  7185. */
  7186. var InputText = /** @class */ (function (_super) {
  7187. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7188. /**
  7189. * Creates a new InputText
  7190. * @param name defines the control name
  7191. * @param text defines the text of the control
  7192. */
  7193. function InputText(name, text) {
  7194. if (text === void 0) { text = ""; }
  7195. var _this = _super.call(this, name) || this;
  7196. _this.name = name;
  7197. _this._text = "";
  7198. _this._placeholderText = "";
  7199. _this._background = "#222222";
  7200. _this._focusedBackground = "#000000";
  7201. _this._focusedColor = "white";
  7202. _this._placeholderColor = "gray";
  7203. _this._thickness = 1;
  7204. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7205. _this._autoStretchWidth = true;
  7206. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7207. _this._isFocused = false;
  7208. _this._blinkIsEven = false;
  7209. _this._cursorOffset = 0;
  7210. _this._deadKey = false;
  7211. _this._addKey = true;
  7212. _this._currentKey = "";
  7213. _this._isTextHighlightOn = false;
  7214. _this._textHighlightColor = "#d5e0ff";
  7215. _this._highligherOpacity = 0.4;
  7216. _this._highlightedText = "";
  7217. _this._startHighlightIndex = 0;
  7218. _this._endHighlightIndex = 0;
  7219. _this._cursorIndex = -1;
  7220. _this._onFocusSelectAll = false;
  7221. _this._isPointerDown = false;
  7222. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7223. _this.promptMessage = "Please enter text:";
  7224. /** Force disable prompt on mobile device */
  7225. _this.disableMobilePrompt = false;
  7226. /** Observable raised when the text changes */
  7227. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7228. /** Observable raised just before an entered character is to be added */
  7229. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7230. /** Observable raised when the control gets the focus */
  7231. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7232. /** Observable raised when the control loses the focus */
  7233. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7234. /**Observable raised when the text is highlighted */
  7235. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7236. /**Observable raised when copy event is triggered */
  7237. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7238. /** Observable raised when cut event is triggered */
  7239. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7240. /** Observable raised when paste event is triggered */
  7241. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7242. /** Observable raised when a key event was processed */
  7243. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7244. _this.text = text;
  7245. _this.isPointerBlocker = true;
  7246. return _this;
  7247. }
  7248. Object.defineProperty(InputText.prototype, "maxWidth", {
  7249. /** Gets or sets the maximum width allowed by the control */
  7250. get: function () {
  7251. return this._maxWidth.toString(this._host);
  7252. },
  7253. set: function (value) {
  7254. if (this._maxWidth.toString(this._host) === value) {
  7255. return;
  7256. }
  7257. if (this._maxWidth.fromString(value)) {
  7258. this._markAsDirty();
  7259. }
  7260. },
  7261. enumerable: false,
  7262. configurable: true
  7263. });
  7264. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7265. /** Gets the maximum width allowed by the control in pixels */
  7266. get: function () {
  7267. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7268. },
  7269. enumerable: false,
  7270. configurable: true
  7271. });
  7272. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7273. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7274. get: function () {
  7275. return this._highligherOpacity;
  7276. },
  7277. set: function (value) {
  7278. if (this._highligherOpacity === value) {
  7279. return;
  7280. }
  7281. this._highligherOpacity = value;
  7282. this._markAsDirty();
  7283. },
  7284. enumerable: false,
  7285. configurable: true
  7286. });
  7287. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7288. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7289. get: function () {
  7290. return this._onFocusSelectAll;
  7291. },
  7292. set: function (value) {
  7293. if (this._onFocusSelectAll === value) {
  7294. return;
  7295. }
  7296. this._onFocusSelectAll = value;
  7297. this._markAsDirty();
  7298. },
  7299. enumerable: false,
  7300. configurable: true
  7301. });
  7302. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7303. /** Gets or sets the text hightlight color */
  7304. get: function () {
  7305. return this._textHighlightColor;
  7306. },
  7307. set: function (value) {
  7308. if (this._textHighlightColor === value) {
  7309. return;
  7310. }
  7311. this._textHighlightColor = value;
  7312. this._markAsDirty();
  7313. },
  7314. enumerable: false,
  7315. configurable: true
  7316. });
  7317. Object.defineProperty(InputText.prototype, "margin", {
  7318. /** Gets or sets control margin */
  7319. get: function () {
  7320. return this._margin.toString(this._host);
  7321. },
  7322. set: function (value) {
  7323. if (this._margin.toString(this._host) === value) {
  7324. return;
  7325. }
  7326. if (this._margin.fromString(value)) {
  7327. this._markAsDirty();
  7328. }
  7329. },
  7330. enumerable: false,
  7331. configurable: true
  7332. });
  7333. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7334. /** Gets control margin in pixels */
  7335. get: function () {
  7336. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7337. },
  7338. enumerable: false,
  7339. configurable: true
  7340. });
  7341. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7342. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7343. get: function () {
  7344. return this._autoStretchWidth;
  7345. },
  7346. set: function (value) {
  7347. if (this._autoStretchWidth === value) {
  7348. return;
  7349. }
  7350. this._autoStretchWidth = value;
  7351. this._markAsDirty();
  7352. },
  7353. enumerable: false,
  7354. configurable: true
  7355. });
  7356. Object.defineProperty(InputText.prototype, "thickness", {
  7357. /** Gets or sets border thickness */
  7358. get: function () {
  7359. return this._thickness;
  7360. },
  7361. set: function (value) {
  7362. if (this._thickness === value) {
  7363. return;
  7364. }
  7365. this._thickness = value;
  7366. this._markAsDirty();
  7367. },
  7368. enumerable: false,
  7369. configurable: true
  7370. });
  7371. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7372. /** Gets or sets the background color when focused */
  7373. get: function () {
  7374. return this._focusedBackground;
  7375. },
  7376. set: function (value) {
  7377. if (this._focusedBackground === value) {
  7378. return;
  7379. }
  7380. this._focusedBackground = value;
  7381. this._markAsDirty();
  7382. },
  7383. enumerable: false,
  7384. configurable: true
  7385. });
  7386. Object.defineProperty(InputText.prototype, "focusedColor", {
  7387. /** Gets or sets the background color when focused */
  7388. get: function () {
  7389. return this._focusedColor;
  7390. },
  7391. set: function (value) {
  7392. if (this._focusedColor === value) {
  7393. return;
  7394. }
  7395. this._focusedColor = value;
  7396. this._markAsDirty();
  7397. },
  7398. enumerable: false,
  7399. configurable: true
  7400. });
  7401. Object.defineProperty(InputText.prototype, "background", {
  7402. /** Gets or sets the background color */
  7403. get: function () {
  7404. return this._background;
  7405. },
  7406. set: function (value) {
  7407. if (this._background === value) {
  7408. return;
  7409. }
  7410. this._background = value;
  7411. this._markAsDirty();
  7412. },
  7413. enumerable: false,
  7414. configurable: true
  7415. });
  7416. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7417. /** Gets or sets the placeholder color */
  7418. get: function () {
  7419. return this._placeholderColor;
  7420. },
  7421. set: function (value) {
  7422. if (this._placeholderColor === value) {
  7423. return;
  7424. }
  7425. this._placeholderColor = value;
  7426. this._markAsDirty();
  7427. },
  7428. enumerable: false,
  7429. configurable: true
  7430. });
  7431. Object.defineProperty(InputText.prototype, "placeholderText", {
  7432. /** Gets or sets the text displayed when the control is empty */
  7433. get: function () {
  7434. return this._placeholderText;
  7435. },
  7436. set: function (value) {
  7437. if (this._placeholderText === value) {
  7438. return;
  7439. }
  7440. this._placeholderText = value;
  7441. this._markAsDirty();
  7442. },
  7443. enumerable: false,
  7444. configurable: true
  7445. });
  7446. Object.defineProperty(InputText.prototype, "deadKey", {
  7447. /** Gets or sets the dead key flag */
  7448. get: function () {
  7449. return this._deadKey;
  7450. },
  7451. set: function (flag) {
  7452. this._deadKey = flag;
  7453. },
  7454. enumerable: false,
  7455. configurable: true
  7456. });
  7457. Object.defineProperty(InputText.prototype, "highlightedText", {
  7458. /** Gets or sets the highlight text */
  7459. get: function () {
  7460. return this._highlightedText;
  7461. },
  7462. set: function (text) {
  7463. if (this._highlightedText === text) {
  7464. return;
  7465. }
  7466. this._highlightedText = text;
  7467. this._markAsDirty();
  7468. },
  7469. enumerable: false,
  7470. configurable: true
  7471. });
  7472. Object.defineProperty(InputText.prototype, "addKey", {
  7473. /** Gets or sets if the current key should be added */
  7474. get: function () {
  7475. return this._addKey;
  7476. },
  7477. set: function (flag) {
  7478. this._addKey = flag;
  7479. },
  7480. enumerable: false,
  7481. configurable: true
  7482. });
  7483. Object.defineProperty(InputText.prototype, "currentKey", {
  7484. /** Gets or sets the value of the current key being entered */
  7485. get: function () {
  7486. return this._currentKey;
  7487. },
  7488. set: function (key) {
  7489. this._currentKey = key;
  7490. },
  7491. enumerable: false,
  7492. configurable: true
  7493. });
  7494. Object.defineProperty(InputText.prototype, "text", {
  7495. /** Gets or sets the text displayed in the control */
  7496. get: function () {
  7497. return this._text;
  7498. },
  7499. set: function (value) {
  7500. var valueAsString = value.toString(); // Forcing convertion
  7501. if (this._text === valueAsString) {
  7502. return;
  7503. }
  7504. this._text = valueAsString;
  7505. this._markAsDirty();
  7506. this.onTextChangedObservable.notifyObservers(this);
  7507. },
  7508. enumerable: false,
  7509. configurable: true
  7510. });
  7511. Object.defineProperty(InputText.prototype, "width", {
  7512. /** Gets or sets control width */
  7513. get: function () {
  7514. return this._width.toString(this._host);
  7515. },
  7516. set: function (value) {
  7517. if (this._width.toString(this._host) === value) {
  7518. return;
  7519. }
  7520. if (this._width.fromString(value)) {
  7521. this._markAsDirty();
  7522. }
  7523. this.autoStretchWidth = false;
  7524. },
  7525. enumerable: false,
  7526. configurable: true
  7527. });
  7528. /** @hidden */
  7529. InputText.prototype.onBlur = function () {
  7530. this._isFocused = false;
  7531. this._scrollLeft = null;
  7532. this._cursorOffset = 0;
  7533. clearTimeout(this._blinkTimeout);
  7534. this._markAsDirty();
  7535. this.onBlurObservable.notifyObservers(this);
  7536. this._host.unRegisterClipboardEvents();
  7537. if (this._onClipboardObserver) {
  7538. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7539. }
  7540. var scene = this._host.getScene();
  7541. if (this._onPointerDblTapObserver && scene) {
  7542. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7543. }
  7544. };
  7545. /** @hidden */
  7546. InputText.prototype.onFocus = function () {
  7547. var _this = this;
  7548. if (!this._isEnabled) {
  7549. return;
  7550. }
  7551. this._scrollLeft = null;
  7552. this._isFocused = true;
  7553. this._blinkIsEven = false;
  7554. this._cursorOffset = 0;
  7555. this._markAsDirty();
  7556. this.onFocusObservable.notifyObservers(this);
  7557. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7558. var value = prompt(this.promptMessage);
  7559. if (value !== null) {
  7560. this.text = value;
  7561. }
  7562. this._host.focusedControl = null;
  7563. return;
  7564. }
  7565. this._host.registerClipboardEvents();
  7566. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7567. // process clipboard event, can be configured.
  7568. switch (clipboardInfo.type) {
  7569. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7570. _this._onCopyText(clipboardInfo.event);
  7571. _this.onTextCopyObservable.notifyObservers(_this);
  7572. break;
  7573. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7574. _this._onCutText(clipboardInfo.event);
  7575. _this.onTextCutObservable.notifyObservers(_this);
  7576. break;
  7577. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7578. _this._onPasteText(clipboardInfo.event);
  7579. _this.onTextPasteObservable.notifyObservers(_this);
  7580. break;
  7581. default: return;
  7582. }
  7583. });
  7584. var scene = this._host.getScene();
  7585. if (scene) {
  7586. //register the pointer double tap event
  7587. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7588. if (!_this._isFocused) {
  7589. return;
  7590. }
  7591. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7592. _this._processDblClick(pointerInfo);
  7593. }
  7594. });
  7595. }
  7596. if (this._onFocusSelectAll) {
  7597. this._selectAllText();
  7598. }
  7599. };
  7600. InputText.prototype._getTypeName = function () {
  7601. return "InputText";
  7602. };
  7603. /**
  7604. * Function called to get the list of controls that should not steal the focus from this control
  7605. * @returns an array of controls
  7606. */
  7607. InputText.prototype.keepsFocusWith = function () {
  7608. if (!this._connectedVirtualKeyboard) {
  7609. return null;
  7610. }
  7611. return [this._connectedVirtualKeyboard];
  7612. };
  7613. /** @hidden */
  7614. InputText.prototype.processKey = function (keyCode, key, evt) {
  7615. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7616. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7617. return;
  7618. }
  7619. //select all
  7620. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7621. this._selectAllText();
  7622. evt.preventDefault();
  7623. return;
  7624. }
  7625. // Specific cases
  7626. switch (keyCode) {
  7627. case 32: //SPACE
  7628. key = " "; //ie11 key for space is "Spacebar"
  7629. break;
  7630. case 191: //SLASH
  7631. if (evt) {
  7632. evt.preventDefault();
  7633. }
  7634. break;
  7635. case 8: // BACKSPACE
  7636. if (this._text && this._text.length > 0) {
  7637. //delete the highlighted text
  7638. if (this._isTextHighlightOn) {
  7639. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7640. this._isTextHighlightOn = false;
  7641. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7642. this._blinkIsEven = false;
  7643. if (evt) {
  7644. evt.preventDefault();
  7645. }
  7646. return;
  7647. }
  7648. //delete single character
  7649. if (this._cursorOffset === 0) {
  7650. this.text = this._text.substr(0, this._text.length - 1);
  7651. }
  7652. else {
  7653. var deletePosition = this._text.length - this._cursorOffset;
  7654. if (deletePosition > 0) {
  7655. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7656. }
  7657. }
  7658. }
  7659. if (evt) {
  7660. evt.preventDefault();
  7661. }
  7662. return;
  7663. case 46: // DELETE
  7664. if (this._isTextHighlightOn) {
  7665. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7666. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7667. while (decrementor > 0 && this._cursorOffset > 0) {
  7668. this._cursorOffset--;
  7669. }
  7670. this._isTextHighlightOn = false;
  7671. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7672. if (evt) {
  7673. evt.preventDefault();
  7674. }
  7675. return;
  7676. }
  7677. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7678. var deletePosition = this._text.length - this._cursorOffset;
  7679. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7680. this._cursorOffset--;
  7681. }
  7682. if (evt) {
  7683. evt.preventDefault();
  7684. }
  7685. return;
  7686. case 13: // RETURN
  7687. this._host.focusedControl = null;
  7688. this._isTextHighlightOn = false;
  7689. return;
  7690. case 35: // END
  7691. this._cursorOffset = 0;
  7692. this._blinkIsEven = false;
  7693. this._isTextHighlightOn = false;
  7694. this._markAsDirty();
  7695. return;
  7696. case 36: // HOME
  7697. this._cursorOffset = this._text.length;
  7698. this._blinkIsEven = false;
  7699. this._isTextHighlightOn = false;
  7700. this._markAsDirty();
  7701. return;
  7702. case 37: // LEFT
  7703. this._cursorOffset++;
  7704. if (this._cursorOffset > this._text.length) {
  7705. this._cursorOffset = this._text.length;
  7706. }
  7707. if (evt && evt.shiftKey) {
  7708. // update the cursor
  7709. this._blinkIsEven = false;
  7710. // shift + ctrl/cmd + <-
  7711. if (evt.ctrlKey || evt.metaKey) {
  7712. if (!this._isTextHighlightOn) {
  7713. if (this._text.length === this._cursorOffset) {
  7714. return;
  7715. }
  7716. else {
  7717. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7718. }
  7719. }
  7720. this._startHighlightIndex = 0;
  7721. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7722. this._cursorOffset = this._text.length;
  7723. this._isTextHighlightOn = true;
  7724. this._markAsDirty();
  7725. return;
  7726. }
  7727. //store the starting point
  7728. if (!this._isTextHighlightOn) {
  7729. this._isTextHighlightOn = true;
  7730. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7731. }
  7732. //if text is already highlighted
  7733. else if (this._cursorIndex === -1) {
  7734. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7735. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7736. }
  7737. //set the highlight indexes
  7738. if (this._cursorIndex < this._cursorOffset) {
  7739. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7740. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7741. }
  7742. else if (this._cursorIndex > this._cursorOffset) {
  7743. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7744. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7745. }
  7746. else {
  7747. this._isTextHighlightOn = false;
  7748. }
  7749. this._markAsDirty();
  7750. return;
  7751. }
  7752. if (this._isTextHighlightOn) {
  7753. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7754. this._isTextHighlightOn = false;
  7755. }
  7756. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7757. this._cursorOffset = this.text.length;
  7758. evt.preventDefault();
  7759. }
  7760. this._blinkIsEven = false;
  7761. this._isTextHighlightOn = false;
  7762. this._cursorIndex = -1;
  7763. this._markAsDirty();
  7764. return;
  7765. case 39: // RIGHT
  7766. this._cursorOffset--;
  7767. if (this._cursorOffset < 0) {
  7768. this._cursorOffset = 0;
  7769. }
  7770. if (evt && evt.shiftKey) {
  7771. //update the cursor
  7772. this._blinkIsEven = false;
  7773. //shift + ctrl/cmd + ->
  7774. if (evt.ctrlKey || evt.metaKey) {
  7775. if (!this._isTextHighlightOn) {
  7776. if (this._cursorOffset === 0) {
  7777. return;
  7778. }
  7779. else {
  7780. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7781. }
  7782. }
  7783. this._endHighlightIndex = this._text.length;
  7784. this._isTextHighlightOn = true;
  7785. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7786. this._cursorOffset = 0;
  7787. this._markAsDirty();
  7788. return;
  7789. }
  7790. if (!this._isTextHighlightOn) {
  7791. this._isTextHighlightOn = true;
  7792. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7793. }
  7794. //if text is already highlighted
  7795. else if (this._cursorIndex === -1) {
  7796. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7797. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7798. }
  7799. //set the highlight indexes
  7800. if (this._cursorIndex < this._cursorOffset) {
  7801. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7802. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7803. }
  7804. else if (this._cursorIndex > this._cursorOffset) {
  7805. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7806. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7807. }
  7808. else {
  7809. this._isTextHighlightOn = false;
  7810. }
  7811. this._markAsDirty();
  7812. return;
  7813. }
  7814. if (this._isTextHighlightOn) {
  7815. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7816. this._isTextHighlightOn = false;
  7817. }
  7818. //ctr + ->
  7819. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7820. this._cursorOffset = 0;
  7821. evt.preventDefault();
  7822. }
  7823. this._blinkIsEven = false;
  7824. this._isTextHighlightOn = false;
  7825. this._cursorIndex = -1;
  7826. this._markAsDirty();
  7827. return;
  7828. case 222: // Dead
  7829. if (evt) {
  7830. evt.preventDefault();
  7831. }
  7832. this._cursorIndex = -1;
  7833. this.deadKey = true;
  7834. break;
  7835. }
  7836. // Printable characters
  7837. if (key &&
  7838. ((keyCode === -1) || // Direct access
  7839. (keyCode === 32) || // Space
  7840. (keyCode > 47 && keyCode < 64) || // Numbers
  7841. (keyCode > 64 && keyCode < 91) || // Letters
  7842. (keyCode > 159 && keyCode < 193) || // Special characters
  7843. (keyCode > 218 && keyCode < 223) || // Special characters
  7844. (keyCode > 95 && keyCode < 112))) { // Numpad
  7845. this._currentKey = key;
  7846. this.onBeforeKeyAddObservable.notifyObservers(this);
  7847. key = this._currentKey;
  7848. if (this._addKey) {
  7849. if (this._isTextHighlightOn) {
  7850. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7851. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7852. this._isTextHighlightOn = false;
  7853. this._blinkIsEven = false;
  7854. this._markAsDirty();
  7855. }
  7856. else if (this._cursorOffset === 0) {
  7857. this.text += key;
  7858. }
  7859. else {
  7860. var insertPosition = this._text.length - this._cursorOffset;
  7861. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7862. }
  7863. }
  7864. }
  7865. };
  7866. /** @hidden */
  7867. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7868. //update the cursor
  7869. this._blinkIsEven = false;
  7870. if (this._cursorIndex === -1) {
  7871. this._cursorIndex = offset;
  7872. }
  7873. else {
  7874. if (this._cursorIndex < this._cursorOffset) {
  7875. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7876. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7877. }
  7878. else if (this._cursorIndex > this._cursorOffset) {
  7879. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7880. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7881. }
  7882. else {
  7883. this._isTextHighlightOn = false;
  7884. this._markAsDirty();
  7885. return;
  7886. }
  7887. }
  7888. this._isTextHighlightOn = true;
  7889. this._markAsDirty();
  7890. };
  7891. /** @hidden */
  7892. InputText.prototype._processDblClick = function (evt) {
  7893. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7894. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7895. this._endHighlightIndex = this._startHighlightIndex;
  7896. var rWord = /\w+/g, moveLeft, moveRight;
  7897. do {
  7898. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7899. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7900. } while (moveLeft || moveRight);
  7901. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7902. this.onTextHighlightObservable.notifyObservers(this);
  7903. this._isTextHighlightOn = true;
  7904. this._clickedCoordinate = null;
  7905. this._blinkIsEven = true;
  7906. this._cursorIndex = -1;
  7907. this._markAsDirty();
  7908. };
  7909. /** @hidden */
  7910. InputText.prototype._selectAllText = function () {
  7911. this._blinkIsEven = true;
  7912. this._isTextHighlightOn = true;
  7913. this._startHighlightIndex = 0;
  7914. this._endHighlightIndex = this._text.length;
  7915. this._cursorOffset = this._text.length;
  7916. this._cursorIndex = -1;
  7917. this._markAsDirty();
  7918. };
  7919. /**
  7920. * Handles the keyboard event
  7921. * @param evt Defines the KeyboardEvent
  7922. */
  7923. InputText.prototype.processKeyboard = function (evt) {
  7924. // process pressed key
  7925. this.processKey(evt.keyCode, evt.key, evt);
  7926. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7927. };
  7928. /** @hidden */
  7929. InputText.prototype._onCopyText = function (ev) {
  7930. this._isTextHighlightOn = false;
  7931. //when write permission to clipbaord data is denied
  7932. try {
  7933. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7934. }
  7935. catch (_a) { } //pass
  7936. this._host.clipboardData = this._highlightedText;
  7937. };
  7938. /** @hidden */
  7939. InputText.prototype._onCutText = function (ev) {
  7940. if (!this._highlightedText) {
  7941. return;
  7942. }
  7943. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7944. this._isTextHighlightOn = false;
  7945. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7946. //when write permission to clipbaord data is denied
  7947. try {
  7948. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7949. }
  7950. catch (_a) { } //pass
  7951. this._host.clipboardData = this._highlightedText;
  7952. this._highlightedText = "";
  7953. };
  7954. /** @hidden */
  7955. InputText.prototype._onPasteText = function (ev) {
  7956. var data = "";
  7957. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7958. data = ev.clipboardData.getData("text/plain");
  7959. }
  7960. else {
  7961. //get the cached data; returns blank string by default
  7962. data = this._host.clipboardData;
  7963. }
  7964. var insertPosition = this._text.length - this._cursorOffset;
  7965. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7966. };
  7967. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7968. var _this = this;
  7969. context.save();
  7970. this._applyStates(context);
  7971. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7972. context.shadowColor = this.shadowColor;
  7973. context.shadowBlur = this.shadowBlur;
  7974. context.shadowOffsetX = this.shadowOffsetX;
  7975. context.shadowOffsetY = this.shadowOffsetY;
  7976. }
  7977. // Background
  7978. if (this._isFocused) {
  7979. if (this._focusedBackground) {
  7980. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7981. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7982. }
  7983. }
  7984. else if (this._background) {
  7985. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7986. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7987. }
  7988. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7989. context.shadowBlur = 0;
  7990. context.shadowOffsetX = 0;
  7991. context.shadowOffsetY = 0;
  7992. }
  7993. if (!this._fontOffset) {
  7994. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7995. }
  7996. // Text
  7997. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7998. if (this.color) {
  7999. context.fillStyle = this.color;
  8000. }
  8001. var text = this._beforeRenderText(this._text);
  8002. if (!this._isFocused && !this._text && this._placeholderText) {
  8003. text = this._placeholderText;
  8004. if (this._placeholderColor) {
  8005. context.fillStyle = this._placeholderColor;
  8006. }
  8007. }
  8008. this._textWidth = context.measureText(text).width;
  8009. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8010. if (this._autoStretchWidth) {
  8011. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8012. }
  8013. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8014. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8015. context.save();
  8016. context.beginPath();
  8017. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8018. context.clip();
  8019. if (this._isFocused && this._textWidth > availableWidth) {
  8020. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8021. if (!this._scrollLeft) {
  8022. this._scrollLeft = textLeft;
  8023. }
  8024. }
  8025. else {
  8026. this._scrollLeft = clipTextLeft;
  8027. }
  8028. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  8029. // Cursor
  8030. if (this._isFocused) {
  8031. // Need to move cursor
  8032. if (this._clickedCoordinate) {
  8033. var rightPosition = this._scrollLeft + this._textWidth;
  8034. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8035. var currentSize = 0;
  8036. this._cursorOffset = 0;
  8037. var previousDist = 0;
  8038. do {
  8039. if (this._cursorOffset) {
  8040. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8041. }
  8042. this._cursorOffset++;
  8043. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8044. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8045. // Find closest move
  8046. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8047. this._cursorOffset--;
  8048. }
  8049. this._blinkIsEven = false;
  8050. this._clickedCoordinate = null;
  8051. }
  8052. // Render cursor
  8053. if (!this._blinkIsEven) {
  8054. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8055. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8056. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8057. if (cursorLeft < clipTextLeft) {
  8058. this._scrollLeft += (clipTextLeft - cursorLeft);
  8059. cursorLeft = clipTextLeft;
  8060. this._markAsDirty();
  8061. }
  8062. else if (cursorLeft > clipTextLeft + availableWidth) {
  8063. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8064. cursorLeft = clipTextLeft + availableWidth;
  8065. this._markAsDirty();
  8066. }
  8067. if (!this._isTextHighlightOn) {
  8068. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8069. }
  8070. }
  8071. clearTimeout(this._blinkTimeout);
  8072. this._blinkTimeout = setTimeout(function () {
  8073. _this._blinkIsEven = !_this._blinkIsEven;
  8074. _this._markAsDirty();
  8075. }, 500);
  8076. //show the highlighted text
  8077. if (this._isTextHighlightOn) {
  8078. clearTimeout(this._blinkTimeout);
  8079. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8080. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8081. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8082. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8083. if (highlightCursorLeft < clipTextLeft) {
  8084. width = width - (clipTextLeft - highlightCursorLeft);
  8085. if (!width) {
  8086. // when using left arrow on text.length > availableWidth;
  8087. // assigns the width of the first letter after clipTextLeft
  8088. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8089. }
  8090. highlightCursorLeft = clipTextLeft;
  8091. }
  8092. //for transparancy
  8093. context.globalAlpha = this._highligherOpacity;
  8094. context.fillStyle = this._textHighlightColor;
  8095. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8096. context.globalAlpha = 1.0;
  8097. }
  8098. }
  8099. context.restore();
  8100. // Border
  8101. if (this._thickness) {
  8102. if (this._isFocused) {
  8103. if (this.focusedColor) {
  8104. context.strokeStyle = this.focusedColor;
  8105. }
  8106. }
  8107. else {
  8108. if (this.color) {
  8109. context.strokeStyle = this.color;
  8110. }
  8111. }
  8112. context.lineWidth = this._thickness;
  8113. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8114. }
  8115. context.restore();
  8116. };
  8117. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8118. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8119. return false;
  8120. }
  8121. this._clickedCoordinate = coordinates.x;
  8122. this._isTextHighlightOn = false;
  8123. this._highlightedText = "";
  8124. this._cursorIndex = -1;
  8125. this._isPointerDown = true;
  8126. this._host._capturingControl[pointerId] = this;
  8127. if (this._host.focusedControl === this) {
  8128. // Move cursor
  8129. clearTimeout(this._blinkTimeout);
  8130. this._markAsDirty();
  8131. return true;
  8132. }
  8133. if (!this._isEnabled) {
  8134. return false;
  8135. }
  8136. this._host.focusedControl = this;
  8137. return true;
  8138. };
  8139. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8140. if (this._host.focusedControl === this && this._isPointerDown) {
  8141. this._clickedCoordinate = coordinates.x;
  8142. this._markAsDirty();
  8143. this._updateValueFromCursorIndex(this._cursorOffset);
  8144. }
  8145. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8146. };
  8147. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8148. this._isPointerDown = false;
  8149. delete this._host._capturingControl[pointerId];
  8150. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8151. };
  8152. InputText.prototype._beforeRenderText = function (text) {
  8153. return text;
  8154. };
  8155. InputText.prototype.dispose = function () {
  8156. _super.prototype.dispose.call(this);
  8157. this.onBlurObservable.clear();
  8158. this.onFocusObservable.clear();
  8159. this.onTextChangedObservable.clear();
  8160. this.onTextCopyObservable.clear();
  8161. this.onTextCutObservable.clear();
  8162. this.onTextPasteObservable.clear();
  8163. this.onTextHighlightObservable.clear();
  8164. this.onKeyboardEventProcessedObservable.clear();
  8165. };
  8166. return InputText;
  8167. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8168. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8169. /***/ }),
  8170. /***/ "./2D/controls/line.ts":
  8171. /*!*****************************!*\
  8172. !*** ./2D/controls/line.ts ***!
  8173. \*****************************/
  8174. /*! exports provided: Line */
  8175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8176. "use strict";
  8177. __webpack_require__.r(__webpack_exports__);
  8178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8179. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8180. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  8181. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8182. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8183. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8184. /** Class used to render 2D lines */
  8185. var Line = /** @class */ (function (_super) {
  8186. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8187. /**
  8188. * Creates a new Line
  8189. * @param name defines the control name
  8190. */
  8191. function Line(name) {
  8192. var _this = _super.call(this, name) || this;
  8193. _this.name = name;
  8194. _this._lineWidth = 1;
  8195. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8196. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8197. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8198. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8199. _this._dash = new Array();
  8200. _this._automaticSize = true;
  8201. _this.isHitTestVisible = false;
  8202. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8203. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8204. return _this;
  8205. }
  8206. Object.defineProperty(Line.prototype, "dash", {
  8207. /** Gets or sets the dash pattern */
  8208. get: function () {
  8209. return this._dash;
  8210. },
  8211. set: function (value) {
  8212. if (this._dash === value) {
  8213. return;
  8214. }
  8215. this._dash = value;
  8216. this._markAsDirty();
  8217. },
  8218. enumerable: false,
  8219. configurable: true
  8220. });
  8221. Object.defineProperty(Line.prototype, "connectedControl", {
  8222. /** Gets or sets the control connected with the line end */
  8223. get: function () {
  8224. return this._connectedControl;
  8225. },
  8226. set: function (value) {
  8227. var _this = this;
  8228. if (this._connectedControl === value) {
  8229. return;
  8230. }
  8231. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8232. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8233. this._connectedControlDirtyObserver = null;
  8234. }
  8235. if (value) {
  8236. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8237. }
  8238. this._connectedControl = value;
  8239. this._markAsDirty();
  8240. },
  8241. enumerable: false,
  8242. configurable: true
  8243. });
  8244. Object.defineProperty(Line.prototype, "x1", {
  8245. /** Gets or sets start coordinates on X axis */
  8246. get: function () {
  8247. return this._x1.toString(this._host);
  8248. },
  8249. set: function (value) {
  8250. if (this._x1.toString(this._host) === value) {
  8251. return;
  8252. }
  8253. if (this._x1.fromString(value)) {
  8254. this._markAsDirty();
  8255. }
  8256. },
  8257. enumerable: false,
  8258. configurable: true
  8259. });
  8260. Object.defineProperty(Line.prototype, "y1", {
  8261. /** Gets or sets start coordinates on Y axis */
  8262. get: function () {
  8263. return this._y1.toString(this._host);
  8264. },
  8265. set: function (value) {
  8266. if (this._y1.toString(this._host) === value) {
  8267. return;
  8268. }
  8269. if (this._y1.fromString(value)) {
  8270. this._markAsDirty();
  8271. }
  8272. },
  8273. enumerable: false,
  8274. configurable: true
  8275. });
  8276. Object.defineProperty(Line.prototype, "x2", {
  8277. /** Gets or sets end coordinates on X axis */
  8278. get: function () {
  8279. return this._x2.toString(this._host);
  8280. },
  8281. set: function (value) {
  8282. if (this._x2.toString(this._host) === value) {
  8283. return;
  8284. }
  8285. if (this._x2.fromString(value)) {
  8286. this._markAsDirty();
  8287. }
  8288. },
  8289. enumerable: false,
  8290. configurable: true
  8291. });
  8292. Object.defineProperty(Line.prototype, "y2", {
  8293. /** Gets or sets end coordinates on Y axis */
  8294. get: function () {
  8295. return this._y2.toString(this._host);
  8296. },
  8297. set: function (value) {
  8298. if (this._y2.toString(this._host) === value) {
  8299. return;
  8300. }
  8301. if (this._y2.fromString(value)) {
  8302. this._markAsDirty();
  8303. }
  8304. },
  8305. enumerable: false,
  8306. configurable: true
  8307. });
  8308. Object.defineProperty(Line.prototype, "lineWidth", {
  8309. /** Gets or sets line width */
  8310. get: function () {
  8311. return this._lineWidth;
  8312. },
  8313. set: function (value) {
  8314. if (this._lineWidth === value) {
  8315. return;
  8316. }
  8317. this._lineWidth = value;
  8318. this._markAsDirty();
  8319. },
  8320. enumerable: false,
  8321. configurable: true
  8322. });
  8323. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8324. /** Gets or sets horizontal alignment */
  8325. set: function (value) {
  8326. return;
  8327. },
  8328. enumerable: false,
  8329. configurable: true
  8330. });
  8331. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8332. /** Gets or sets vertical alignment */
  8333. set: function (value) {
  8334. return;
  8335. },
  8336. enumerable: false,
  8337. configurable: true
  8338. });
  8339. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8340. get: function () {
  8341. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8342. },
  8343. enumerable: false,
  8344. configurable: true
  8345. });
  8346. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8347. get: function () {
  8348. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8349. },
  8350. enumerable: false,
  8351. configurable: true
  8352. });
  8353. Line.prototype._getTypeName = function () {
  8354. return "Line";
  8355. };
  8356. Line.prototype._draw = function (context) {
  8357. context.save();
  8358. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8359. context.shadowColor = this.shadowColor;
  8360. context.shadowBlur = this.shadowBlur;
  8361. context.shadowOffsetX = this.shadowOffsetX;
  8362. context.shadowOffsetY = this.shadowOffsetY;
  8363. }
  8364. this._applyStates(context);
  8365. context.strokeStyle = this.color;
  8366. context.lineWidth = this._lineWidth;
  8367. context.setLineDash(this._dash);
  8368. context.beginPath();
  8369. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8370. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8371. context.stroke();
  8372. context.restore();
  8373. };
  8374. Line.prototype._measure = function () {
  8375. // Width / Height
  8376. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8377. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8378. };
  8379. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8380. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8381. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8382. };
  8383. /**
  8384. * Move one end of the line given 3D cartesian coordinates.
  8385. * @param position Targeted world position
  8386. * @param scene Scene
  8387. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8388. */
  8389. Line.prototype.moveToVector3 = function (position, scene, end) {
  8390. if (end === void 0) { end = false; }
  8391. if (!this._host || this.parent !== this._host._rootContainer) {
  8392. 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");
  8393. return;
  8394. }
  8395. var globalViewport = this._host._getGlobalViewport(scene);
  8396. 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);
  8397. this._moveToProjectedPosition(projectedPosition, end);
  8398. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8399. this.notRenderable = true;
  8400. return;
  8401. }
  8402. this.notRenderable = false;
  8403. };
  8404. /**
  8405. * Move one end of the line to a position in screen absolute space.
  8406. * @param projectedPosition Position in screen absolute space (X, Y)
  8407. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8408. */
  8409. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8410. if (end === void 0) { end = false; }
  8411. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8412. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8413. if (end) {
  8414. this.x2 = x;
  8415. this.y2 = y;
  8416. this._x2.ignoreAdaptiveScaling = true;
  8417. this._y2.ignoreAdaptiveScaling = true;
  8418. }
  8419. else {
  8420. this.x1 = x;
  8421. this.y1 = y;
  8422. this._x1.ignoreAdaptiveScaling = true;
  8423. this._y1.ignoreAdaptiveScaling = true;
  8424. }
  8425. };
  8426. return Line;
  8427. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8428. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8429. /***/ }),
  8430. /***/ "./2D/controls/multiLine.ts":
  8431. /*!**********************************!*\
  8432. !*** ./2D/controls/multiLine.ts ***!
  8433. \**********************************/
  8434. /*! exports provided: MultiLine */
  8435. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8436. "use strict";
  8437. __webpack_require__.r(__webpack_exports__);
  8438. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8439. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8440. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8441. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8442. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8443. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8444. /**
  8445. * Class used to create multi line control
  8446. */
  8447. var MultiLine = /** @class */ (function (_super) {
  8448. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8449. /**
  8450. * Creates a new MultiLine
  8451. * @param name defines the control name
  8452. */
  8453. function MultiLine(name) {
  8454. var _this = _super.call(this, name) || this;
  8455. _this.name = name;
  8456. _this._lineWidth = 1;
  8457. /** Function called when a point is updated */
  8458. _this.onPointUpdate = function () {
  8459. _this._markAsDirty();
  8460. };
  8461. _this._automaticSize = true;
  8462. _this.isHitTestVisible = false;
  8463. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8464. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8465. _this._dash = [];
  8466. _this._points = [];
  8467. return _this;
  8468. }
  8469. Object.defineProperty(MultiLine.prototype, "dash", {
  8470. /** Gets or sets dash pattern */
  8471. get: function () {
  8472. return this._dash;
  8473. },
  8474. set: function (value) {
  8475. if (this._dash === value) {
  8476. return;
  8477. }
  8478. this._dash = value;
  8479. this._markAsDirty();
  8480. },
  8481. enumerable: false,
  8482. configurable: true
  8483. });
  8484. /**
  8485. * Gets point stored at specified index
  8486. * @param index defines the index to look for
  8487. * @returns the requested point if found
  8488. */
  8489. MultiLine.prototype.getAt = function (index) {
  8490. if (!this._points[index]) {
  8491. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8492. }
  8493. return this._points[index];
  8494. };
  8495. /**
  8496. * Adds new points to the point collection
  8497. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8498. * @returns the list of created MultiLinePoint
  8499. */
  8500. MultiLine.prototype.add = function () {
  8501. var _this = this;
  8502. var items = [];
  8503. for (var _i = 0; _i < arguments.length; _i++) {
  8504. items[_i] = arguments[_i];
  8505. }
  8506. return items.map(function (item) { return _this.push(item); });
  8507. };
  8508. /**
  8509. * Adds a new point to the point collection
  8510. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8511. * @returns the created MultiLinePoint
  8512. */
  8513. MultiLine.prototype.push = function (item) {
  8514. var point = this.getAt(this._points.length);
  8515. if (item == null) {
  8516. return point;
  8517. }
  8518. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8519. point.mesh = item;
  8520. }
  8521. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8522. point.control = item;
  8523. }
  8524. else if (item.x != null && item.y != null) {
  8525. point.x = item.x;
  8526. point.y = item.y;
  8527. }
  8528. return point;
  8529. };
  8530. /**
  8531. * Remove a specific value or point from the active point collection
  8532. * @param value defines the value or point to remove
  8533. */
  8534. MultiLine.prototype.remove = function (value) {
  8535. var index;
  8536. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8537. index = this._points.indexOf(value);
  8538. if (index === -1) {
  8539. return;
  8540. }
  8541. }
  8542. else {
  8543. index = value;
  8544. }
  8545. var point = this._points[index];
  8546. if (!point) {
  8547. return;
  8548. }
  8549. point.dispose();
  8550. this._points.splice(index, 1);
  8551. };
  8552. /**
  8553. * Resets this object to initial state (no point)
  8554. */
  8555. MultiLine.prototype.reset = function () {
  8556. while (this._points.length > 0) {
  8557. this.remove(this._points.length - 1);
  8558. }
  8559. };
  8560. /**
  8561. * Resets all links
  8562. */
  8563. MultiLine.prototype.resetLinks = function () {
  8564. this._points.forEach(function (point) {
  8565. if (point != null) {
  8566. point.resetLinks();
  8567. }
  8568. });
  8569. };
  8570. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8571. /** Gets or sets line width */
  8572. get: function () {
  8573. return this._lineWidth;
  8574. },
  8575. set: function (value) {
  8576. if (this._lineWidth === value) {
  8577. return;
  8578. }
  8579. this._lineWidth = value;
  8580. this._markAsDirty();
  8581. },
  8582. enumerable: false,
  8583. configurable: true
  8584. });
  8585. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8586. set: function (value) {
  8587. return;
  8588. },
  8589. enumerable: false,
  8590. configurable: true
  8591. });
  8592. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8593. set: function (value) {
  8594. return;
  8595. },
  8596. enumerable: false,
  8597. configurable: true
  8598. });
  8599. MultiLine.prototype._getTypeName = function () {
  8600. return "MultiLine";
  8601. };
  8602. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8603. context.save();
  8604. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8605. context.shadowColor = this.shadowColor;
  8606. context.shadowBlur = this.shadowBlur;
  8607. context.shadowOffsetX = this.shadowOffsetX;
  8608. context.shadowOffsetY = this.shadowOffsetY;
  8609. }
  8610. this._applyStates(context);
  8611. context.strokeStyle = this.color;
  8612. context.lineWidth = this._lineWidth;
  8613. context.setLineDash(this._dash);
  8614. context.beginPath();
  8615. var first = true; //first index is not necessarily 0
  8616. this._points.forEach(function (point) {
  8617. if (!point) {
  8618. return;
  8619. }
  8620. if (first) {
  8621. context.moveTo(point._point.x, point._point.y);
  8622. first = false;
  8623. }
  8624. else {
  8625. context.lineTo(point._point.x, point._point.y);
  8626. }
  8627. });
  8628. context.stroke();
  8629. context.restore();
  8630. };
  8631. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8632. var _this = this;
  8633. this._minX = null;
  8634. this._minY = null;
  8635. this._maxX = null;
  8636. this._maxY = null;
  8637. this._points.forEach(function (point, index) {
  8638. if (!point) {
  8639. return;
  8640. }
  8641. point.translate();
  8642. if (_this._minX == null || point._point.x < _this._minX) {
  8643. _this._minX = point._point.x;
  8644. }
  8645. if (_this._minY == null || point._point.y < _this._minY) {
  8646. _this._minY = point._point.y;
  8647. }
  8648. if (_this._maxX == null || point._point.x > _this._maxX) {
  8649. _this._maxX = point._point.x;
  8650. }
  8651. if (_this._maxY == null || point._point.y > _this._maxY) {
  8652. _this._maxY = point._point.y;
  8653. }
  8654. });
  8655. if (this._minX == null) {
  8656. this._minX = 0;
  8657. }
  8658. if (this._minY == null) {
  8659. this._minY = 0;
  8660. }
  8661. if (this._maxX == null) {
  8662. this._maxX = 0;
  8663. }
  8664. if (this._maxY == null) {
  8665. this._maxY = 0;
  8666. }
  8667. };
  8668. MultiLine.prototype._measure = function () {
  8669. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8670. return;
  8671. }
  8672. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8673. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8674. };
  8675. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8676. if (this._minX == null || this._minY == null) {
  8677. return;
  8678. }
  8679. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8680. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8681. };
  8682. MultiLine.prototype.dispose = function () {
  8683. this.reset();
  8684. _super.prototype.dispose.call(this);
  8685. };
  8686. return MultiLine;
  8687. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8688. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8689. /***/ }),
  8690. /***/ "./2D/controls/radioButton.ts":
  8691. /*!************************************!*\
  8692. !*** ./2D/controls/radioButton.ts ***!
  8693. \************************************/
  8694. /*! exports provided: RadioButton */
  8695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8696. "use strict";
  8697. __webpack_require__.r(__webpack_exports__);
  8698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8699. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8700. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8701. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8702. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8703. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8704. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8705. /**
  8706. * Class used to create radio button controls
  8707. */
  8708. var RadioButton = /** @class */ (function (_super) {
  8709. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8710. /**
  8711. * Creates a new RadioButton
  8712. * @param name defines the control name
  8713. */
  8714. function RadioButton(name) {
  8715. var _this = _super.call(this, name) || this;
  8716. _this.name = name;
  8717. _this._isChecked = false;
  8718. _this._background = "black";
  8719. _this._checkSizeRatio = 0.8;
  8720. _this._thickness = 1;
  8721. /** Gets or sets group name */
  8722. _this.group = "";
  8723. /** Observable raised when isChecked is changed */
  8724. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8725. _this.isPointerBlocker = true;
  8726. return _this;
  8727. }
  8728. Object.defineProperty(RadioButton.prototype, "thickness", {
  8729. /** Gets or sets border thickness */
  8730. get: function () {
  8731. return this._thickness;
  8732. },
  8733. set: function (value) {
  8734. if (this._thickness === value) {
  8735. return;
  8736. }
  8737. this._thickness = value;
  8738. this._markAsDirty();
  8739. },
  8740. enumerable: false,
  8741. configurable: true
  8742. });
  8743. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8744. /** Gets or sets a value indicating the ratio between overall size and check size */
  8745. get: function () {
  8746. return this._checkSizeRatio;
  8747. },
  8748. set: function (value) {
  8749. value = Math.max(Math.min(1, value), 0);
  8750. if (this._checkSizeRatio === value) {
  8751. return;
  8752. }
  8753. this._checkSizeRatio = value;
  8754. this._markAsDirty();
  8755. },
  8756. enumerable: false,
  8757. configurable: true
  8758. });
  8759. Object.defineProperty(RadioButton.prototype, "background", {
  8760. /** Gets or sets background color */
  8761. get: function () {
  8762. return this._background;
  8763. },
  8764. set: function (value) {
  8765. if (this._background === value) {
  8766. return;
  8767. }
  8768. this._background = value;
  8769. this._markAsDirty();
  8770. },
  8771. enumerable: false,
  8772. configurable: true
  8773. });
  8774. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8775. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8776. get: function () {
  8777. return this._isChecked;
  8778. },
  8779. set: function (value) {
  8780. var _this = this;
  8781. if (this._isChecked === value) {
  8782. return;
  8783. }
  8784. this._isChecked = value;
  8785. this._markAsDirty();
  8786. this.onIsCheckedChangedObservable.notifyObservers(value);
  8787. if (this._isChecked && this._host) {
  8788. // Update all controls from same group
  8789. this._host.executeOnAllControls(function (control) {
  8790. if (control === _this) {
  8791. return;
  8792. }
  8793. if (control.group === undefined) {
  8794. return;
  8795. }
  8796. var childRadio = control;
  8797. if (childRadio.group === _this.group) {
  8798. childRadio.isChecked = false;
  8799. }
  8800. });
  8801. }
  8802. },
  8803. enumerable: false,
  8804. configurable: true
  8805. });
  8806. RadioButton.prototype._getTypeName = function () {
  8807. return "RadioButton";
  8808. };
  8809. RadioButton.prototype._draw = function (context) {
  8810. context.save();
  8811. this._applyStates(context);
  8812. var actualWidth = this._currentMeasure.width - this._thickness;
  8813. var actualHeight = this._currentMeasure.height - this._thickness;
  8814. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8815. context.shadowColor = this.shadowColor;
  8816. context.shadowBlur = this.shadowBlur;
  8817. context.shadowOffsetX = this.shadowOffsetX;
  8818. context.shadowOffsetY = this.shadowOffsetY;
  8819. }
  8820. // Outer
  8821. _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);
  8822. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8823. context.fill();
  8824. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8825. context.shadowBlur = 0;
  8826. context.shadowOffsetX = 0;
  8827. context.shadowOffsetY = 0;
  8828. }
  8829. context.strokeStyle = this.color;
  8830. context.lineWidth = this._thickness;
  8831. context.stroke();
  8832. // Inner
  8833. if (this._isChecked) {
  8834. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8835. var offsetWidth = actualWidth * this._checkSizeRatio;
  8836. var offseHeight = actualHeight * this._checkSizeRatio;
  8837. _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);
  8838. context.fill();
  8839. }
  8840. context.restore();
  8841. };
  8842. // Events
  8843. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8844. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8845. return false;
  8846. }
  8847. if (!this.isChecked) {
  8848. this.isChecked = true;
  8849. }
  8850. return true;
  8851. };
  8852. /**
  8853. * Utility function to easily create a radio button with a header
  8854. * @param title defines the label to use for the header
  8855. * @param group defines the group to use for the radio button
  8856. * @param isChecked defines the initial state of the radio button
  8857. * @param onValueChanged defines the callback to call when value changes
  8858. * @returns a StackPanel containing the radio button and a textBlock
  8859. */
  8860. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8861. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8862. panel.isVertical = false;
  8863. panel.height = "30px";
  8864. var radio = new RadioButton();
  8865. radio.width = "20px";
  8866. radio.height = "20px";
  8867. radio.isChecked = isChecked;
  8868. radio.color = "green";
  8869. radio.group = group;
  8870. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8871. panel.addControl(radio);
  8872. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8873. header.text = title;
  8874. header.width = "180px";
  8875. header.paddingLeft = "5px";
  8876. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8877. header.color = "white";
  8878. panel.addControl(header);
  8879. return panel;
  8880. };
  8881. return RadioButton;
  8882. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8883. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8884. /***/ }),
  8885. /***/ "./2D/controls/rectangle.ts":
  8886. /*!**********************************!*\
  8887. !*** ./2D/controls/rectangle.ts ***!
  8888. \**********************************/
  8889. /*! exports provided: Rectangle */
  8890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8891. "use strict";
  8892. __webpack_require__.r(__webpack_exports__);
  8893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8894. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8895. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8896. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8897. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8898. /** Class used to create rectangle container */
  8899. var Rectangle = /** @class */ (function (_super) {
  8900. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8901. /**
  8902. * Creates a new Rectangle
  8903. * @param name defines the control name
  8904. */
  8905. function Rectangle(name) {
  8906. var _this = _super.call(this, name) || this;
  8907. _this.name = name;
  8908. _this._thickness = 1;
  8909. _this._cornerRadius = 0;
  8910. return _this;
  8911. }
  8912. Object.defineProperty(Rectangle.prototype, "thickness", {
  8913. /** Gets or sets border thickness */
  8914. get: function () {
  8915. return this._thickness;
  8916. },
  8917. set: function (value) {
  8918. if (this._thickness === value) {
  8919. return;
  8920. }
  8921. this._thickness = value;
  8922. this._markAsDirty();
  8923. },
  8924. enumerable: false,
  8925. configurable: true
  8926. });
  8927. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8928. /** Gets or sets the corner radius angle */
  8929. get: function () {
  8930. return this._cornerRadius;
  8931. },
  8932. set: function (value) {
  8933. if (value < 0) {
  8934. value = 0;
  8935. }
  8936. if (this._cornerRadius === value) {
  8937. return;
  8938. }
  8939. this._cornerRadius = value;
  8940. this._markAsDirty();
  8941. },
  8942. enumerable: false,
  8943. configurable: true
  8944. });
  8945. Rectangle.prototype._getTypeName = function () {
  8946. return "Rectangle";
  8947. };
  8948. Rectangle.prototype._localDraw = function (context) {
  8949. context.save();
  8950. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8951. context.shadowColor = this.shadowColor;
  8952. context.shadowBlur = this.shadowBlur;
  8953. context.shadowOffsetX = this.shadowOffsetX;
  8954. context.shadowOffsetY = this.shadowOffsetY;
  8955. }
  8956. if (this._background) {
  8957. context.fillStyle = this._background;
  8958. if (this._cornerRadius) {
  8959. this._drawRoundedRect(context, this._thickness / 2);
  8960. context.fill();
  8961. }
  8962. else {
  8963. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8964. }
  8965. }
  8966. if (this._thickness) {
  8967. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8968. context.shadowBlur = 0;
  8969. context.shadowOffsetX = 0;
  8970. context.shadowOffsetY = 0;
  8971. }
  8972. if (this.color) {
  8973. context.strokeStyle = this.color;
  8974. }
  8975. context.lineWidth = this._thickness;
  8976. if (this._cornerRadius) {
  8977. this._drawRoundedRect(context, this._thickness / 2);
  8978. context.stroke();
  8979. }
  8980. else {
  8981. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8982. }
  8983. }
  8984. context.restore();
  8985. };
  8986. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8987. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8988. this._measureForChildren.width -= 2 * this._thickness;
  8989. this._measureForChildren.height -= 2 * this._thickness;
  8990. this._measureForChildren.left += this._thickness;
  8991. this._measureForChildren.top += this._thickness;
  8992. };
  8993. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8994. if (offset === void 0) { offset = 0; }
  8995. var x = this._currentMeasure.left + offset;
  8996. var y = this._currentMeasure.top + offset;
  8997. var width = this._currentMeasure.width - offset * 2;
  8998. var height = this._currentMeasure.height - offset * 2;
  8999. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9000. context.beginPath();
  9001. context.moveTo(x + radius, y);
  9002. context.lineTo(x + width - radius, y);
  9003. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9004. context.lineTo(x + width, y + height - radius);
  9005. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9006. context.lineTo(x + radius, y + height);
  9007. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9008. context.lineTo(x, y + radius);
  9009. context.quadraticCurveTo(x, y, x + radius, y);
  9010. context.closePath();
  9011. };
  9012. Rectangle.prototype._clipForChildren = function (context) {
  9013. if (this._cornerRadius) {
  9014. this._drawRoundedRect(context, this._thickness);
  9015. context.clip();
  9016. }
  9017. };
  9018. return Rectangle;
  9019. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9020. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9021. /***/ }),
  9022. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9023. /*!***************************************************!*\
  9024. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9025. \***************************************************/
  9026. /*! exports provided: ScrollViewer */
  9027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9028. "use strict";
  9029. __webpack_require__.r(__webpack_exports__);
  9030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9031. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9032. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9033. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9034. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9035. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9036. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9037. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9038. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  9039. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9040. /**
  9041. * Class used to hold a viewer window and sliders in a grid
  9042. */
  9043. var ScrollViewer = /** @class */ (function (_super) {
  9044. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9045. /**
  9046. * Creates a new ScrollViewer
  9047. * @param name of ScrollViewer
  9048. */
  9049. function ScrollViewer(name, isImageBased) {
  9050. var _this = _super.call(this, name) || this;
  9051. _this._barSize = 20;
  9052. _this._pointerIsOver = false;
  9053. _this._wheelPrecision = 0.05;
  9054. _this._thumbLength = 0.5;
  9055. _this._thumbHeight = 1;
  9056. _this._barImageHeight = 1;
  9057. _this._horizontalBarImageHeight = 1;
  9058. _this._verticalBarImageHeight = 1;
  9059. _this._oldWindowContentsWidth = 0;
  9060. _this._oldWindowContentsHeight = 0;
  9061. _this._forceHorizontalBar = false;
  9062. _this._forceVerticalBar = false;
  9063. _this._useImageBar = isImageBased ? isImageBased : false;
  9064. _this.onDirtyObservable.add(function () {
  9065. _this._horizontalBarSpace.color = _this.color;
  9066. _this._verticalBarSpace.color = _this.color;
  9067. _this._dragSpace.color = _this.color;
  9068. });
  9069. _this.onPointerEnterObservable.add(function () {
  9070. _this._pointerIsOver = true;
  9071. });
  9072. _this.onPointerOutObservable.add(function () {
  9073. _this._pointerIsOver = false;
  9074. });
  9075. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9076. if (_this._useImageBar) {
  9077. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9078. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9079. }
  9080. else {
  9081. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9082. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9083. }
  9084. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9085. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9086. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9087. _this._grid.addColumnDefinition(1);
  9088. _this._grid.addColumnDefinition(0, true);
  9089. _this._grid.addRowDefinition(1);
  9090. _this._grid.addRowDefinition(0, true);
  9091. _super.prototype.addControl.call(_this, _this._grid);
  9092. _this._grid.addControl(_this._window, 0, 0);
  9093. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9094. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9095. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9096. _this._verticalBarSpace.thickness = 1;
  9097. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9098. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9099. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9100. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9101. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9102. _this._horizontalBarSpace.thickness = 1;
  9103. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9104. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9105. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9106. _this._dragSpace.thickness = 1;
  9107. _this._grid.addControl(_this._dragSpace, 1, 1);
  9108. // Colors
  9109. if (!_this._useImageBar) {
  9110. _this.barColor = "grey";
  9111. _this.barBackground = "transparent";
  9112. }
  9113. return _this;
  9114. }
  9115. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9116. /**
  9117. * Gets the horizontal scrollbar
  9118. */
  9119. get: function () {
  9120. return this._horizontalBar;
  9121. },
  9122. enumerable: false,
  9123. configurable: true
  9124. });
  9125. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9126. /**
  9127. * Gets the vertical scrollbar
  9128. */
  9129. get: function () {
  9130. return this._verticalBar;
  9131. },
  9132. enumerable: false,
  9133. configurable: true
  9134. });
  9135. /**
  9136. * Adds a new control to the current container
  9137. * @param control defines the control to add
  9138. * @returns the current container
  9139. */
  9140. ScrollViewer.prototype.addControl = function (control) {
  9141. if (!control) {
  9142. return this;
  9143. }
  9144. this._window.addControl(control);
  9145. return this;
  9146. };
  9147. /**
  9148. * Removes a control from the current container
  9149. * @param control defines the control to remove
  9150. * @returns the current container
  9151. */
  9152. ScrollViewer.prototype.removeControl = function (control) {
  9153. this._window.removeControl(control);
  9154. return this;
  9155. };
  9156. Object.defineProperty(ScrollViewer.prototype, "children", {
  9157. /** Gets the list of children */
  9158. get: function () {
  9159. return this._window.children;
  9160. },
  9161. enumerable: false,
  9162. configurable: true
  9163. });
  9164. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9165. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9166. var child = _a[_i];
  9167. child._markMatrixAsDirty();
  9168. }
  9169. };
  9170. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9171. /**
  9172. * Freezes or unfreezes the controls in the window.
  9173. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9174. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9175. */
  9176. get: function () {
  9177. return this._window.freezeControls;
  9178. },
  9179. set: function (value) {
  9180. this._window.freezeControls = value;
  9181. },
  9182. enumerable: false,
  9183. configurable: true
  9184. });
  9185. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9186. /** Gets the bucket width */
  9187. get: function () {
  9188. return this._window.bucketWidth;
  9189. },
  9190. enumerable: false,
  9191. configurable: true
  9192. });
  9193. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9194. /** Gets the bucket height */
  9195. get: function () {
  9196. return this._window.bucketHeight;
  9197. },
  9198. enumerable: false,
  9199. configurable: true
  9200. });
  9201. /**
  9202. * Sets the bucket sizes.
  9203. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9204. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9205. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9206. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9207. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9208. * used), that's why it is not enabled by default.
  9209. * @param width width of the bucket
  9210. * @param height height of the bucket
  9211. */
  9212. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9213. this._window.setBucketSizes(width, height);
  9214. };
  9215. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9216. /**
  9217. * Forces the horizontal scroll bar to be displayed
  9218. */
  9219. get: function () {
  9220. return this._forceHorizontalBar;
  9221. },
  9222. set: function (value) {
  9223. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9224. this._horizontalBar.isVisible = value;
  9225. this._forceHorizontalBar = value;
  9226. },
  9227. enumerable: false,
  9228. configurable: true
  9229. });
  9230. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9231. /**
  9232. * Forces the vertical scroll bar to be displayed
  9233. */
  9234. get: function () {
  9235. return this._forceVerticalBar;
  9236. },
  9237. set: function (value) {
  9238. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9239. this._verticalBar.isVisible = value;
  9240. this._forceVerticalBar = value;
  9241. },
  9242. enumerable: false,
  9243. configurable: true
  9244. });
  9245. /** Reset the scroll viewer window to initial size */
  9246. ScrollViewer.prototype.resetWindow = function () {
  9247. this._window.width = "100%";
  9248. this._window.height = "100%";
  9249. };
  9250. ScrollViewer.prototype._getTypeName = function () {
  9251. return "ScrollViewer";
  9252. };
  9253. ScrollViewer.prototype._buildClientSizes = function () {
  9254. var ratio = this.host.idealRatio;
  9255. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9256. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9257. this._clientWidth = this._window.parentClientWidth;
  9258. this._clientHeight = this._window.parentClientHeight;
  9259. };
  9260. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9261. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9262. this._buildClientSizes();
  9263. };
  9264. ScrollViewer.prototype._postMeasure = function () {
  9265. _super.prototype._postMeasure.call(this);
  9266. this._updateScroller();
  9267. this._setWindowPosition(false);
  9268. };
  9269. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9270. /**
  9271. * Gets or sets the mouse wheel precision
  9272. * from 0 to 1 with a default value of 0.05
  9273. * */
  9274. get: function () {
  9275. return this._wheelPrecision;
  9276. },
  9277. set: function (value) {
  9278. if (this._wheelPrecision === value) {
  9279. return;
  9280. }
  9281. if (value < 0) {
  9282. value = 0;
  9283. }
  9284. if (value > 1) {
  9285. value = 1;
  9286. }
  9287. this._wheelPrecision = value;
  9288. },
  9289. enumerable: false,
  9290. configurable: true
  9291. });
  9292. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9293. /** Gets or sets the scroll bar container background color */
  9294. get: function () {
  9295. return this._horizontalBarSpace.background;
  9296. },
  9297. set: function (color) {
  9298. if (this._horizontalBarSpace.background === color) {
  9299. return;
  9300. }
  9301. this._horizontalBarSpace.background = color;
  9302. this._verticalBarSpace.background = color;
  9303. },
  9304. enumerable: false,
  9305. configurable: true
  9306. });
  9307. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9308. /** Gets or sets the bar color */
  9309. get: function () {
  9310. return this._barColor;
  9311. },
  9312. set: function (color) {
  9313. if (this._barColor === color) {
  9314. return;
  9315. }
  9316. this._barColor = color;
  9317. this._horizontalBar.color = color;
  9318. this._verticalBar.color = color;
  9319. },
  9320. enumerable: false,
  9321. configurable: true
  9322. });
  9323. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9324. /** Gets or sets the bar image */
  9325. get: function () {
  9326. return this._barImage;
  9327. },
  9328. set: function (value) {
  9329. if (this._barImage === value) {
  9330. return;
  9331. }
  9332. this._barImage = value;
  9333. var hb = this._horizontalBar;
  9334. var vb = this._verticalBar;
  9335. hb.thumbImage = value;
  9336. vb.thumbImage = value;
  9337. },
  9338. enumerable: false,
  9339. configurable: true
  9340. });
  9341. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9342. /** Gets or sets the horizontal bar image */
  9343. get: function () {
  9344. return this._horizontalBarImage;
  9345. },
  9346. set: function (value) {
  9347. if (this._horizontalBarImage === value) {
  9348. return;
  9349. }
  9350. this._horizontalBarImage = value;
  9351. var hb = this._horizontalBar;
  9352. hb.thumbImage = value;
  9353. },
  9354. enumerable: false,
  9355. configurable: true
  9356. });
  9357. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9358. /** Gets or sets the vertical bar image */
  9359. get: function () {
  9360. return this._verticalBarImage;
  9361. },
  9362. set: function (value) {
  9363. if (this._verticalBarImage === value) {
  9364. return;
  9365. }
  9366. this._verticalBarImage = value;
  9367. var vb = this._verticalBar;
  9368. vb.thumbImage = value;
  9369. },
  9370. enumerable: false,
  9371. configurable: true
  9372. });
  9373. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9374. /** Gets or sets the size of the bar */
  9375. get: function () {
  9376. return this._barSize;
  9377. },
  9378. set: function (value) {
  9379. if (this._barSize === value) {
  9380. return;
  9381. }
  9382. this._barSize = value;
  9383. this._markAsDirty();
  9384. if (this._horizontalBar.isVisible) {
  9385. this._grid.setRowDefinition(1, this._barSize, true);
  9386. }
  9387. if (this._verticalBar.isVisible) {
  9388. this._grid.setColumnDefinition(1, this._barSize, true);
  9389. }
  9390. },
  9391. enumerable: false,
  9392. configurable: true
  9393. });
  9394. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9395. /** Gets or sets the length of the thumb */
  9396. get: function () {
  9397. return this._thumbLength;
  9398. },
  9399. set: function (value) {
  9400. if (this._thumbLength === value) {
  9401. return;
  9402. }
  9403. if (value <= 0) {
  9404. value = 0.1;
  9405. }
  9406. if (value > 1) {
  9407. value = 1;
  9408. }
  9409. this._thumbLength = value;
  9410. var hb = this._horizontalBar;
  9411. var vb = this._verticalBar;
  9412. hb.thumbLength = value;
  9413. vb.thumbLength = value;
  9414. this._markAsDirty();
  9415. },
  9416. enumerable: false,
  9417. configurable: true
  9418. });
  9419. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9420. /** Gets or sets the height of the thumb */
  9421. get: function () {
  9422. return this._thumbHeight;
  9423. },
  9424. set: function (value) {
  9425. if (this._thumbHeight === value) {
  9426. return;
  9427. }
  9428. if (value <= 0) {
  9429. value = 0.1;
  9430. }
  9431. if (value > 1) {
  9432. value = 1;
  9433. }
  9434. this._thumbHeight = value;
  9435. var hb = this._horizontalBar;
  9436. var vb = this._verticalBar;
  9437. hb.thumbHeight = value;
  9438. vb.thumbHeight = value;
  9439. this._markAsDirty();
  9440. },
  9441. enumerable: false,
  9442. configurable: true
  9443. });
  9444. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9445. /** Gets or sets the height of the bar image */
  9446. get: function () {
  9447. return this._barImageHeight;
  9448. },
  9449. set: function (value) {
  9450. if (this._barImageHeight === value) {
  9451. return;
  9452. }
  9453. if (value <= 0) {
  9454. value = 0.1;
  9455. }
  9456. if (value > 1) {
  9457. value = 1;
  9458. }
  9459. this._barImageHeight = value;
  9460. var hb = this._horizontalBar;
  9461. var vb = this._verticalBar;
  9462. hb.barImageHeight = value;
  9463. vb.barImageHeight = value;
  9464. this._markAsDirty();
  9465. },
  9466. enumerable: false,
  9467. configurable: true
  9468. });
  9469. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9470. /** Gets or sets the height of the horizontal bar image */
  9471. get: function () {
  9472. return this._horizontalBarImageHeight;
  9473. },
  9474. set: function (value) {
  9475. if (this._horizontalBarImageHeight === value) {
  9476. return;
  9477. }
  9478. if (value <= 0) {
  9479. value = 0.1;
  9480. }
  9481. if (value > 1) {
  9482. value = 1;
  9483. }
  9484. this._horizontalBarImageHeight = value;
  9485. var hb = this._horizontalBar;
  9486. hb.barImageHeight = value;
  9487. this._markAsDirty();
  9488. },
  9489. enumerable: false,
  9490. configurable: true
  9491. });
  9492. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9493. /** Gets or sets the height of the vertical bar image */
  9494. get: function () {
  9495. return this._verticalBarImageHeight;
  9496. },
  9497. set: function (value) {
  9498. if (this._verticalBarImageHeight === value) {
  9499. return;
  9500. }
  9501. if (value <= 0) {
  9502. value = 0.1;
  9503. }
  9504. if (value > 1) {
  9505. value = 1;
  9506. }
  9507. this._verticalBarImageHeight = value;
  9508. var vb = this._verticalBar;
  9509. vb.barImageHeight = value;
  9510. this._markAsDirty();
  9511. },
  9512. enumerable: false,
  9513. configurable: true
  9514. });
  9515. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9516. /** Gets or sets the bar background */
  9517. get: function () {
  9518. return this._barBackground;
  9519. },
  9520. set: function (color) {
  9521. if (this._barBackground === color) {
  9522. return;
  9523. }
  9524. this._barBackground = color;
  9525. var hb = this._horizontalBar;
  9526. var vb = this._verticalBar;
  9527. hb.background = color;
  9528. vb.background = color;
  9529. this._dragSpace.background = color;
  9530. },
  9531. enumerable: false,
  9532. configurable: true
  9533. });
  9534. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9535. /** Gets or sets the bar background image */
  9536. get: function () {
  9537. return this._barBackgroundImage;
  9538. },
  9539. set: function (value) {
  9540. if (this._barBackgroundImage === value) {
  9541. }
  9542. this._barBackgroundImage = value;
  9543. var hb = this._horizontalBar;
  9544. var vb = this._verticalBar;
  9545. hb.backgroundImage = value;
  9546. vb.backgroundImage = value;
  9547. },
  9548. enumerable: false,
  9549. configurable: true
  9550. });
  9551. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9552. /** Gets or sets the horizontal bar background image */
  9553. get: function () {
  9554. return this._horizontalBarBackgroundImage;
  9555. },
  9556. set: function (value) {
  9557. if (this._horizontalBarBackgroundImage === value) {
  9558. }
  9559. this._horizontalBarBackgroundImage = value;
  9560. var hb = this._horizontalBar;
  9561. hb.backgroundImage = value;
  9562. },
  9563. enumerable: false,
  9564. configurable: true
  9565. });
  9566. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9567. /** Gets or sets the vertical bar background image */
  9568. get: function () {
  9569. return this._verticalBarBackgroundImage;
  9570. },
  9571. set: function (value) {
  9572. if (this._verticalBarBackgroundImage === value) {
  9573. }
  9574. this._verticalBarBackgroundImage = value;
  9575. var vb = this._verticalBar;
  9576. vb.backgroundImage = value;
  9577. },
  9578. enumerable: false,
  9579. configurable: true
  9580. });
  9581. ScrollViewer.prototype._setWindowPosition = function (force) {
  9582. if (force === void 0) { force = true; }
  9583. var ratio = this.host.idealRatio;
  9584. var windowContentsWidth = this._window._currentMeasure.width;
  9585. var windowContentsHeight = this._window._currentMeasure.height;
  9586. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9587. return;
  9588. }
  9589. this._oldWindowContentsWidth = windowContentsWidth;
  9590. this._oldWindowContentsHeight = windowContentsHeight;
  9591. var _endLeft = this._clientWidth - windowContentsWidth;
  9592. var _endTop = this._clientHeight - windowContentsHeight;
  9593. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9594. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9595. if (newLeft !== this._window.left) {
  9596. this._window.left = newLeft;
  9597. if (!this.freezeControls) {
  9598. this._rebuildLayout = true;
  9599. }
  9600. }
  9601. if (newTop !== this._window.top) {
  9602. this._window.top = newTop;
  9603. if (!this.freezeControls) {
  9604. this._rebuildLayout = true;
  9605. }
  9606. }
  9607. };
  9608. /** @hidden */
  9609. ScrollViewer.prototype._updateScroller = function () {
  9610. var windowContentsWidth = this._window._currentMeasure.width;
  9611. var windowContentsHeight = this._window._currentMeasure.height;
  9612. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9613. this._grid.setRowDefinition(1, 0, true);
  9614. this._horizontalBar.isVisible = false;
  9615. this._horizontalBar.value = 0;
  9616. this._rebuildLayout = true;
  9617. }
  9618. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9619. this._grid.setRowDefinition(1, this._barSize, true);
  9620. this._horizontalBar.isVisible = true;
  9621. this._rebuildLayout = true;
  9622. }
  9623. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9624. this._grid.setColumnDefinition(1, 0, true);
  9625. this._verticalBar.isVisible = false;
  9626. this._verticalBar.value = 0;
  9627. this._rebuildLayout = true;
  9628. }
  9629. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9630. this._grid.setColumnDefinition(1, this._barSize, true);
  9631. this._verticalBar.isVisible = true;
  9632. this._rebuildLayout = true;
  9633. }
  9634. this._buildClientSizes();
  9635. var ratio = this.host.idealRatio;
  9636. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9637. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9638. };
  9639. ScrollViewer.prototype._link = function (host) {
  9640. _super.prototype._link.call(this, host);
  9641. this._attachWheel();
  9642. };
  9643. /** @hidden */
  9644. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9645. var _this = this;
  9646. barControl.paddingLeft = 0;
  9647. barControl.width = "100%";
  9648. barControl.height = "100%";
  9649. barControl.barOffset = 0;
  9650. barControl.value = 0;
  9651. barControl.maximum = 1;
  9652. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9653. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9654. barControl.isVertical = isVertical;
  9655. barControl.rotation = rotation;
  9656. barControl.isVisible = false;
  9657. barContainer.addControl(barControl);
  9658. barControl.onValueChangedObservable.add(function (value) {
  9659. _this._setWindowPosition();
  9660. });
  9661. };
  9662. /** @hidden */
  9663. ScrollViewer.prototype._attachWheel = function () {
  9664. var _this = this;
  9665. if (!this._host || this._onWheelObserver) {
  9666. return;
  9667. }
  9668. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9669. if (!_this._pointerIsOver) {
  9670. return;
  9671. }
  9672. if (_this._verticalBar.isVisible == true) {
  9673. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9674. _this._verticalBar.value -= _this._wheelPrecision;
  9675. }
  9676. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9677. _this._verticalBar.value += _this._wheelPrecision;
  9678. }
  9679. }
  9680. if (_this._horizontalBar.isVisible == true) {
  9681. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9682. _this._horizontalBar.value += _this._wheelPrecision;
  9683. }
  9684. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9685. _this._horizontalBar.value -= _this._wheelPrecision;
  9686. }
  9687. }
  9688. });
  9689. };
  9690. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9691. if (!this.isHighlighted) {
  9692. return;
  9693. }
  9694. _super.prototype._renderHighlightSpecific.call(this, context);
  9695. this._grid._renderHighlightSpecific(context);
  9696. context.restore();
  9697. };
  9698. /** Releases associated resources */
  9699. ScrollViewer.prototype.dispose = function () {
  9700. this.onWheelObservable.remove(this._onWheelObserver);
  9701. this._onWheelObserver = null;
  9702. _super.prototype.dispose.call(this);
  9703. };
  9704. return ScrollViewer;
  9705. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9706. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9707. /***/ }),
  9708. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9709. /*!*********************************************************!*\
  9710. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9711. \*********************************************************/
  9712. /*! exports provided: _ScrollViewerWindow */
  9713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9714. "use strict";
  9715. __webpack_require__.r(__webpack_exports__);
  9716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9718. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9719. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9720. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9721. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9722. /**
  9723. * Class used to hold a the container for ScrollViewer
  9724. * @hidden
  9725. */
  9726. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9727. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9728. /**
  9729. * Creates a new ScrollViewerWindow
  9730. * @param name of ScrollViewerWindow
  9731. */
  9732. function _ScrollViewerWindow(name) {
  9733. var _this = _super.call(this, name) || this;
  9734. _this._freezeControls = false;
  9735. _this._bucketWidth = 0;
  9736. _this._bucketHeight = 0;
  9737. _this._buckets = {};
  9738. return _this;
  9739. }
  9740. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9741. get: function () {
  9742. return this._freezeControls;
  9743. },
  9744. set: function (value) {
  9745. if (this._freezeControls === value) {
  9746. return;
  9747. }
  9748. if (!value) {
  9749. this._restoreMeasures();
  9750. }
  9751. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9752. this._freezeControls = false;
  9753. var textureSize = this.host.getSize();
  9754. var renderWidth = textureSize.width;
  9755. var renderHeight = textureSize.height;
  9756. var context = this.host.getContext();
  9757. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9758. this.host._numLayoutCalls = 0;
  9759. this.host._rootContainer._layout(measure, context);
  9760. // in freeze mode, prepare children measures accordingly
  9761. if (value) {
  9762. this._updateMeasures();
  9763. if (this._useBuckets()) {
  9764. this._makeBuckets();
  9765. }
  9766. }
  9767. this._freezeControls = value;
  9768. this.host.markAsDirty(); // redraw with the (new) current settings
  9769. },
  9770. enumerable: false,
  9771. configurable: true
  9772. });
  9773. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9774. get: function () {
  9775. return this._bucketWidth;
  9776. },
  9777. enumerable: false,
  9778. configurable: true
  9779. });
  9780. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9781. get: function () {
  9782. return this._bucketHeight;
  9783. },
  9784. enumerable: false,
  9785. configurable: true
  9786. });
  9787. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9788. this._bucketWidth = width;
  9789. this._bucketHeight = height;
  9790. if (this._useBuckets()) {
  9791. if (this._freezeControls) {
  9792. this._makeBuckets();
  9793. }
  9794. }
  9795. else {
  9796. this._buckets = {};
  9797. }
  9798. };
  9799. _ScrollViewerWindow.prototype._useBuckets = function () {
  9800. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9801. };
  9802. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9803. this._buckets = {};
  9804. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9805. this._dispatchInBuckets(this._children);
  9806. this._oldLeft = null;
  9807. this._oldTop = null;
  9808. };
  9809. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9810. for (var i = 0; i < children.length; ++i) {
  9811. var child = children[i];
  9812. 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);
  9813. while (bStartY <= bEndY) {
  9814. for (var x = bStartX; x <= bEndX; ++x) {
  9815. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9816. if (!lstc) {
  9817. lstc = [];
  9818. this._buckets[bucket] = lstc;
  9819. }
  9820. lstc.push(child);
  9821. }
  9822. bStartY++;
  9823. }
  9824. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9825. this._dispatchInBuckets(child._children);
  9826. }
  9827. }
  9828. };
  9829. // reset left and top measures for the window and all its children
  9830. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9831. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9832. this._measureForChildren.left -= left;
  9833. this._measureForChildren.top -= top;
  9834. this._currentMeasure.left -= left;
  9835. this._currentMeasure.top -= top;
  9836. this._customData.origLeftForChildren = this._measureForChildren.left;
  9837. this._customData.origTopForChildren = this._measureForChildren.top;
  9838. this._customData.origLeft = this._currentMeasure.left;
  9839. this._customData.origTop = this._currentMeasure.top;
  9840. this._updateChildrenMeasures(this._children, left, top);
  9841. };
  9842. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9843. for (var i = 0; i < children.length; ++i) {
  9844. var child = children[i];
  9845. child._currentMeasure.left -= left;
  9846. child._currentMeasure.top -= top;
  9847. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9848. child._customData._origTop = child._currentMeasure.top;
  9849. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9850. this._updateChildrenMeasures(child._children, left, top);
  9851. }
  9852. }
  9853. };
  9854. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  9855. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9856. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  9857. this._measureForChildren.top = this._customData.origTopForChildren + top;
  9858. this._currentMeasure.left = this._customData.origLeft + left;
  9859. this._currentMeasure.top = this._customData.origTop + top;
  9860. };
  9861. _ScrollViewerWindow.prototype._getTypeName = function () {
  9862. return "ScrollViewerWindow";
  9863. };
  9864. /** @hidden */
  9865. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9866. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9867. this._parentMeasure = parentMeasure;
  9868. this._measureForChildren.left = this._currentMeasure.left;
  9869. this._measureForChildren.top = this._currentMeasure.top;
  9870. this._measureForChildren.width = parentMeasure.width;
  9871. this._measureForChildren.height = parentMeasure.height;
  9872. };
  9873. /** @hidden */
  9874. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9875. if (this._freezeControls) {
  9876. this.invalidateRect(); // will trigger a redraw of the window
  9877. return false;
  9878. }
  9879. return _super.prototype._layout.call(this, parentMeasure, context);
  9880. };
  9881. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9882. for (var i = 0; i < children.length; ++i) {
  9883. var child = children[i];
  9884. child._currentMeasure.left = child._customData._origLeft + left;
  9885. child._currentMeasure.top = child._customData._origTop + top;
  9886. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9887. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9888. this._scrollChildren(child._children, left, top);
  9889. }
  9890. }
  9891. };
  9892. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9893. 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);
  9894. while (bStartY <= bEndY) {
  9895. for (var x = bStartX; x <= bEndX; ++x) {
  9896. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9897. if (lstc) {
  9898. for (var i = 0; i < lstc.length; ++i) {
  9899. var child = lstc[i];
  9900. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9901. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9902. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9903. }
  9904. }
  9905. }
  9906. bStartY++;
  9907. }
  9908. };
  9909. /** @hidden */
  9910. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9911. if (!this._freezeControls) {
  9912. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9913. return;
  9914. }
  9915. this._localDraw(context);
  9916. if (this.clipChildren) {
  9917. this._clipForChildren(context);
  9918. }
  9919. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9920. if (this._useBuckets()) {
  9921. if (this._oldLeft !== null && this._oldTop !== null) {
  9922. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9923. this._scrollChildrenWithBuckets(left, top, left, top);
  9924. }
  9925. else {
  9926. this._scrollChildren(this._children, left, top);
  9927. }
  9928. }
  9929. else {
  9930. this._scrollChildren(this._children, left, top);
  9931. }
  9932. this._oldLeft = left;
  9933. this._oldTop = top;
  9934. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9935. var child = _a[_i];
  9936. if (!child._intersectsRect(this._parentMeasure)) {
  9937. continue;
  9938. }
  9939. child._render(context, this._parentMeasure);
  9940. }
  9941. };
  9942. _ScrollViewerWindow.prototype._postMeasure = function () {
  9943. if (this._freezeControls) {
  9944. _super.prototype._postMeasure.call(this);
  9945. return;
  9946. }
  9947. var maxWidth = this.parentClientWidth;
  9948. var maxHeight = this.parentClientHeight;
  9949. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9950. var child = _a[_i];
  9951. if (!child.isVisible || child.notRenderable) {
  9952. continue;
  9953. }
  9954. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9955. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9956. }
  9957. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9958. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9959. }
  9960. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9961. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9962. }
  9963. if (this._currentMeasure.width !== maxWidth) {
  9964. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9965. this._currentMeasure.width = maxWidth;
  9966. this._rebuildLayout = true;
  9967. this._isDirty = true;
  9968. }
  9969. if (this._currentMeasure.height !== maxHeight) {
  9970. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9971. this._currentMeasure.height = maxHeight;
  9972. this._rebuildLayout = true;
  9973. this._isDirty = true;
  9974. }
  9975. _super.prototype._postMeasure.call(this);
  9976. };
  9977. return _ScrollViewerWindow;
  9978. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9979. /***/ }),
  9980. /***/ "./2D/controls/selector.ts":
  9981. /*!*********************************!*\
  9982. !*** ./2D/controls/selector.ts ***!
  9983. \*********************************/
  9984. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9986. "use strict";
  9987. __webpack_require__.r(__webpack_exports__);
  9988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9993. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9994. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9995. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9996. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9997. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9998. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9999. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10000. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10001. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10002. /** Class used to create a RadioGroup
  10003. * which contains groups of radio buttons
  10004. */
  10005. var SelectorGroup = /** @class */ (function () {
  10006. /**
  10007. * Creates a new SelectorGroup
  10008. * @param name of group, used as a group heading
  10009. */
  10010. function SelectorGroup(
  10011. /** name of SelectorGroup */
  10012. name) {
  10013. this.name = name;
  10014. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10015. this._selectors = new Array();
  10016. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10017. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10018. this._groupHeader = this._addGroupHeader(name);
  10019. }
  10020. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10021. /** Gets the groupPanel of the SelectorGroup */
  10022. get: function () {
  10023. return this._groupPanel;
  10024. },
  10025. enumerable: false,
  10026. configurable: true
  10027. });
  10028. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10029. /** Gets the selectors array */
  10030. get: function () {
  10031. return this._selectors;
  10032. },
  10033. enumerable: false,
  10034. configurable: true
  10035. });
  10036. Object.defineProperty(SelectorGroup.prototype, "header", {
  10037. /** Gets and sets the group header */
  10038. get: function () {
  10039. return this._groupHeader.text;
  10040. },
  10041. set: function (label) {
  10042. if (this._groupHeader.text === "label") {
  10043. return;
  10044. }
  10045. this._groupHeader.text = label;
  10046. },
  10047. enumerable: false,
  10048. configurable: true
  10049. });
  10050. /** @hidden */
  10051. SelectorGroup.prototype._addGroupHeader = function (text) {
  10052. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10053. groupHeading.width = 0.9;
  10054. groupHeading.height = "30px";
  10055. groupHeading.textWrapping = true;
  10056. groupHeading.color = "black";
  10057. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10058. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10059. groupHeading.left = "2px";
  10060. this._groupPanel.addControl(groupHeading);
  10061. return groupHeading;
  10062. };
  10063. /** @hidden*/
  10064. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10065. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10066. return;
  10067. }
  10068. return this._selectors[selectorNb];
  10069. };
  10070. /** Removes the selector at the given position
  10071. * @param selectorNb the position of the selector within the group
  10072. */
  10073. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10074. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10075. return;
  10076. }
  10077. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10078. this._selectors.splice(selectorNb, 1);
  10079. };
  10080. return SelectorGroup;
  10081. }());
  10082. /** Class used to create a CheckboxGroup
  10083. * which contains groups of checkbox buttons
  10084. */
  10085. var CheckboxGroup = /** @class */ (function (_super) {
  10086. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10087. function CheckboxGroup() {
  10088. return _super !== null && _super.apply(this, arguments) || this;
  10089. }
  10090. /** Adds a checkbox as a control
  10091. * @param text is the label for the selector
  10092. * @param func is the function called when the Selector is checked
  10093. * @param checked is true when Selector is checked
  10094. */
  10095. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10096. if (func === void 0) { func = function (s) { }; }
  10097. if (checked === void 0) { checked = false; }
  10098. var checked = checked || false;
  10099. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10100. button.width = "20px";
  10101. button.height = "20px";
  10102. button.color = "#364249";
  10103. button.background = "#CCCCCC";
  10104. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10105. button.onIsCheckedChangedObservable.add(function (state) {
  10106. func(state);
  10107. });
  10108. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10109. _selector.height = "30px";
  10110. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10111. _selector.left = "4px";
  10112. this.groupPanel.addControl(_selector);
  10113. this.selectors.push(_selector);
  10114. button.isChecked = checked;
  10115. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10116. button.color = this.groupPanel.parent.parent.buttonColor;
  10117. button.background = this.groupPanel.parent.parent.buttonBackground;
  10118. }
  10119. };
  10120. /** @hidden */
  10121. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10122. this.selectors[selectorNb].children[1].text = label;
  10123. };
  10124. /** @hidden */
  10125. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10126. this.selectors[selectorNb].children[1].color = color;
  10127. };
  10128. /** @hidden */
  10129. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10130. this.selectors[selectorNb].children[0].color = color;
  10131. };
  10132. /** @hidden */
  10133. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10134. this.selectors[selectorNb].children[0].background = color;
  10135. };
  10136. return CheckboxGroup;
  10137. }(SelectorGroup));
  10138. /** Class used to create a RadioGroup
  10139. * which contains groups of radio buttons
  10140. */
  10141. var RadioGroup = /** @class */ (function (_super) {
  10142. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10143. function RadioGroup() {
  10144. var _this = _super !== null && _super.apply(this, arguments) || this;
  10145. _this._selectNb = 0;
  10146. return _this;
  10147. }
  10148. /** Adds a radio button as a control
  10149. * @param label is the label for the selector
  10150. * @param func is the function called when the Selector is checked
  10151. * @param checked is true when Selector is checked
  10152. */
  10153. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10154. if (func === void 0) { func = function (n) { }; }
  10155. if (checked === void 0) { checked = false; }
  10156. var nb = this._selectNb++;
  10157. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10158. button.name = label;
  10159. button.width = "20px";
  10160. button.height = "20px";
  10161. button.color = "#364249";
  10162. button.background = "#CCCCCC";
  10163. button.group = this.name;
  10164. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10165. button.onIsCheckedChangedObservable.add(function (state) {
  10166. if (state) {
  10167. func(nb);
  10168. }
  10169. });
  10170. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10171. _selector.height = "30px";
  10172. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10173. _selector.left = "4px";
  10174. this.groupPanel.addControl(_selector);
  10175. this.selectors.push(_selector);
  10176. button.isChecked = checked;
  10177. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10178. button.color = this.groupPanel.parent.parent.buttonColor;
  10179. button.background = this.groupPanel.parent.parent.buttonBackground;
  10180. }
  10181. };
  10182. /** @hidden */
  10183. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10184. this.selectors[selectorNb].children[1].text = label;
  10185. };
  10186. /** @hidden */
  10187. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10188. this.selectors[selectorNb].children[1].color = color;
  10189. };
  10190. /** @hidden */
  10191. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10192. this.selectors[selectorNb].children[0].color = color;
  10193. };
  10194. /** @hidden */
  10195. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10196. this.selectors[selectorNb].children[0].background = color;
  10197. };
  10198. return RadioGroup;
  10199. }(SelectorGroup));
  10200. /** Class used to create a SliderGroup
  10201. * which contains groups of slider buttons
  10202. */
  10203. var SliderGroup = /** @class */ (function (_super) {
  10204. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10205. function SliderGroup() {
  10206. return _super !== null && _super.apply(this, arguments) || this;
  10207. }
  10208. /**
  10209. * Adds a slider to the SelectorGroup
  10210. * @param label is the label for the SliderBar
  10211. * @param func is the function called when the Slider moves
  10212. * @param unit is a string describing the units used, eg degrees or metres
  10213. * @param min is the minimum value for the Slider
  10214. * @param max is the maximum value for the Slider
  10215. * @param value is the start value for the Slider between min and max
  10216. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10217. */
  10218. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10219. if (func === void 0) { func = function (v) { }; }
  10220. if (unit === void 0) { unit = "Units"; }
  10221. if (min === void 0) { min = 0; }
  10222. if (max === void 0) { max = 0; }
  10223. if (value === void 0) { value = 0; }
  10224. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10225. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10226. button.name = unit;
  10227. button.value = value;
  10228. button.minimum = min;
  10229. button.maximum = max;
  10230. button.width = 0.9;
  10231. button.height = "20px";
  10232. button.color = "#364249";
  10233. button.background = "#CCCCCC";
  10234. button.borderColor = "black";
  10235. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10236. button.left = "4px";
  10237. button.paddingBottom = "4px";
  10238. button.onValueChangedObservable.add(function (value) {
  10239. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10240. func(value);
  10241. });
  10242. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10243. _selector.height = "60px";
  10244. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10245. _selector.left = "4px";
  10246. _selector.children[0].name = label;
  10247. this.groupPanel.addControl(_selector);
  10248. this.selectors.push(_selector);
  10249. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10250. button.color = this.groupPanel.parent.parent.buttonColor;
  10251. button.background = this.groupPanel.parent.parent.buttonBackground;
  10252. }
  10253. };
  10254. /** @hidden */
  10255. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10256. this.selectors[selectorNb].children[0].name = label;
  10257. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10258. };
  10259. /** @hidden */
  10260. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10261. this.selectors[selectorNb].children[0].color = color;
  10262. };
  10263. /** @hidden */
  10264. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10265. this.selectors[selectorNb].children[1].color = color;
  10266. };
  10267. /** @hidden */
  10268. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10269. this.selectors[selectorNb].children[1].background = color;
  10270. };
  10271. return SliderGroup;
  10272. }(SelectorGroup));
  10273. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10274. * @see https://doc.babylonjs.com/how_to/selector
  10275. */
  10276. var SelectionPanel = /** @class */ (function (_super) {
  10277. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10278. /**
  10279. * Creates a new SelectionPanel
  10280. * @param name of SelectionPanel
  10281. * @param groups is an array of SelectionGroups
  10282. */
  10283. function SelectionPanel(
  10284. /** name of SelectionPanel */
  10285. name,
  10286. /** an array of SelectionGroups */
  10287. groups) {
  10288. if (groups === void 0) { groups = []; }
  10289. var _this = _super.call(this, name) || this;
  10290. _this.name = name;
  10291. _this.groups = groups;
  10292. _this._buttonColor = "#364249";
  10293. _this._buttonBackground = "#CCCCCC";
  10294. _this._headerColor = "black";
  10295. _this._barColor = "white";
  10296. _this._barHeight = "2px";
  10297. _this._spacerHeight = "20px";
  10298. _this._bars = new Array();
  10299. _this._groups = groups;
  10300. _this.thickness = 2;
  10301. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10302. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10303. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10304. _this._panel.top = 5;
  10305. _this._panel.left = 5;
  10306. _this._panel.width = 0.95;
  10307. if (groups.length > 0) {
  10308. for (var i = 0; i < groups.length - 1; i++) {
  10309. _this._panel.addControl(groups[i].groupPanel);
  10310. _this._addSpacer();
  10311. }
  10312. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10313. }
  10314. _this.addControl(_this._panel);
  10315. return _this;
  10316. }
  10317. SelectionPanel.prototype._getTypeName = function () {
  10318. return "SelectionPanel";
  10319. };
  10320. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10321. /** Gets or sets the headerColor */
  10322. get: function () {
  10323. return this._headerColor;
  10324. },
  10325. set: function (color) {
  10326. if (this._headerColor === color) {
  10327. return;
  10328. }
  10329. this._headerColor = color;
  10330. this._setHeaderColor();
  10331. },
  10332. enumerable: false,
  10333. configurable: true
  10334. });
  10335. SelectionPanel.prototype._setHeaderColor = function () {
  10336. for (var i = 0; i < this._groups.length; i++) {
  10337. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10338. }
  10339. };
  10340. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10341. /** Gets or sets the button color */
  10342. get: function () {
  10343. return this._buttonColor;
  10344. },
  10345. set: function (color) {
  10346. if (this._buttonColor === color) {
  10347. return;
  10348. }
  10349. this._buttonColor = color;
  10350. this._setbuttonColor();
  10351. },
  10352. enumerable: false,
  10353. configurable: true
  10354. });
  10355. SelectionPanel.prototype._setbuttonColor = function () {
  10356. for (var i = 0; i < this._groups.length; i++) {
  10357. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10358. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10359. }
  10360. }
  10361. };
  10362. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10363. /** Gets or sets the label color */
  10364. get: function () {
  10365. return this._labelColor;
  10366. },
  10367. set: function (color) {
  10368. if (this._labelColor === color) {
  10369. return;
  10370. }
  10371. this._labelColor = color;
  10372. this._setLabelColor();
  10373. },
  10374. enumerable: false,
  10375. configurable: true
  10376. });
  10377. SelectionPanel.prototype._setLabelColor = function () {
  10378. for (var i = 0; i < this._groups.length; i++) {
  10379. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10380. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10381. }
  10382. }
  10383. };
  10384. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10385. /** Gets or sets the button background */
  10386. get: function () {
  10387. return this._buttonBackground;
  10388. },
  10389. set: function (color) {
  10390. if (this._buttonBackground === color) {
  10391. return;
  10392. }
  10393. this._buttonBackground = color;
  10394. this._setButtonBackground();
  10395. },
  10396. enumerable: false,
  10397. configurable: true
  10398. });
  10399. SelectionPanel.prototype._setButtonBackground = function () {
  10400. for (var i = 0; i < this._groups.length; i++) {
  10401. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10402. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10403. }
  10404. }
  10405. };
  10406. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10407. /** Gets or sets the color of separator bar */
  10408. get: function () {
  10409. return this._barColor;
  10410. },
  10411. set: function (color) {
  10412. if (this._barColor === color) {
  10413. return;
  10414. }
  10415. this._barColor = color;
  10416. this._setBarColor();
  10417. },
  10418. enumerable: false,
  10419. configurable: true
  10420. });
  10421. SelectionPanel.prototype._setBarColor = function () {
  10422. for (var i = 0; i < this._bars.length; i++) {
  10423. this._bars[i].children[0].background = this._barColor;
  10424. }
  10425. };
  10426. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10427. /** Gets or sets the height of separator bar */
  10428. get: function () {
  10429. return this._barHeight;
  10430. },
  10431. set: function (value) {
  10432. if (this._barHeight === value) {
  10433. return;
  10434. }
  10435. this._barHeight = value;
  10436. this._setBarHeight();
  10437. },
  10438. enumerable: false,
  10439. configurable: true
  10440. });
  10441. SelectionPanel.prototype._setBarHeight = function () {
  10442. for (var i = 0; i < this._bars.length; i++) {
  10443. this._bars[i].children[0].height = this._barHeight;
  10444. }
  10445. };
  10446. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10447. /** Gets or sets the height of spacers*/
  10448. get: function () {
  10449. return this._spacerHeight;
  10450. },
  10451. set: function (value) {
  10452. if (this._spacerHeight === value) {
  10453. return;
  10454. }
  10455. this._spacerHeight = value;
  10456. this._setSpacerHeight();
  10457. },
  10458. enumerable: false,
  10459. configurable: true
  10460. });
  10461. SelectionPanel.prototype._setSpacerHeight = function () {
  10462. for (var i = 0; i < this._bars.length; i++) {
  10463. this._bars[i].height = this._spacerHeight;
  10464. }
  10465. };
  10466. /** Adds a bar between groups */
  10467. SelectionPanel.prototype._addSpacer = function () {
  10468. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10469. separator.width = 1;
  10470. separator.height = this._spacerHeight;
  10471. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10472. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10473. bar.width = 1;
  10474. bar.height = this._barHeight;
  10475. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10476. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10477. bar.background = this._barColor;
  10478. bar.color = "transparent";
  10479. separator.addControl(bar);
  10480. this._panel.addControl(separator);
  10481. this._bars.push(separator);
  10482. };
  10483. /** Add a group to the selection panel
  10484. * @param group is the selector group to add
  10485. */
  10486. SelectionPanel.prototype.addGroup = function (group) {
  10487. if (this._groups.length > 0) {
  10488. this._addSpacer();
  10489. }
  10490. this._panel.addControl(group.groupPanel);
  10491. this._groups.push(group);
  10492. group.groupPanel.children[0].color = this._headerColor;
  10493. for (var j = 0; j < group.selectors.length; j++) {
  10494. group._setSelectorButtonColor(j, this._buttonColor);
  10495. group._setSelectorButtonBackground(j, this._buttonBackground);
  10496. }
  10497. };
  10498. /** Remove the group from the given position
  10499. * @param groupNb is the position of the group in the list
  10500. */
  10501. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10502. if (groupNb < 0 || groupNb >= this._groups.length) {
  10503. return;
  10504. }
  10505. var group = this._groups[groupNb];
  10506. this._panel.removeControl(group.groupPanel);
  10507. this._groups.splice(groupNb, 1);
  10508. if (groupNb < this._bars.length) {
  10509. this._panel.removeControl(this._bars[groupNb]);
  10510. this._bars.splice(groupNb, 1);
  10511. }
  10512. };
  10513. /** Change a group header label
  10514. * @param label is the new group header label
  10515. * @param groupNb is the number of the group to relabel
  10516. * */
  10517. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10518. if (groupNb < 0 || groupNb >= this._groups.length) {
  10519. return;
  10520. }
  10521. var group = this._groups[groupNb];
  10522. group.groupPanel.children[0].text = label;
  10523. };
  10524. /** Change selector label to the one given
  10525. * @param label is the new selector label
  10526. * @param groupNb is the number of the groupcontaining the selector
  10527. * @param selectorNb is the number of the selector within a group to relabel
  10528. * */
  10529. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10530. if (groupNb < 0 || groupNb >= this._groups.length) {
  10531. return;
  10532. }
  10533. var group = this._groups[groupNb];
  10534. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10535. return;
  10536. }
  10537. group._setSelectorLabel(selectorNb, label);
  10538. };
  10539. /** For a given group position remove the selector at the given position
  10540. * @param groupNb is the number of the group to remove the selector from
  10541. * @param selectorNb is the number of the selector within the group
  10542. */
  10543. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10544. if (groupNb < 0 || groupNb >= this._groups.length) {
  10545. return;
  10546. }
  10547. var group = this._groups[groupNb];
  10548. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10549. return;
  10550. }
  10551. group.removeSelector(selectorNb);
  10552. };
  10553. /** For a given group position of correct type add a checkbox button
  10554. * @param groupNb is the number of the group to remove the selector from
  10555. * @param label is the label for the selector
  10556. * @param func is the function called when the Selector is checked
  10557. * @param checked is true when Selector is checked
  10558. */
  10559. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10560. if (func === void 0) { func = function () { }; }
  10561. if (checked === void 0) { checked = false; }
  10562. if (groupNb < 0 || groupNb >= this._groups.length) {
  10563. return;
  10564. }
  10565. var group = this._groups[groupNb];
  10566. group.addCheckbox(label, func, checked);
  10567. };
  10568. /** For a given group position of correct type add a radio button
  10569. * @param groupNb is the number of the group to remove the selector from
  10570. * @param label is the label for the selector
  10571. * @param func is the function called when the Selector is checked
  10572. * @param checked is true when Selector is checked
  10573. */
  10574. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10575. if (func === void 0) { func = function () { }; }
  10576. if (checked === void 0) { checked = false; }
  10577. if (groupNb < 0 || groupNb >= this._groups.length) {
  10578. return;
  10579. }
  10580. var group = this._groups[groupNb];
  10581. group.addRadio(label, func, checked);
  10582. };
  10583. /**
  10584. * For a given slider group add a slider
  10585. * @param groupNb is the number of the group to add the slider to
  10586. * @param label is the label for the Slider
  10587. * @param func is the function called when the Slider moves
  10588. * @param unit is a string describing the units used, eg degrees or metres
  10589. * @param min is the minimum value for the Slider
  10590. * @param max is the maximum value for the Slider
  10591. * @param value is the start value for the Slider between min and max
  10592. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10593. */
  10594. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10595. if (func === void 0) { func = function () { }; }
  10596. if (unit === void 0) { unit = "Units"; }
  10597. if (min === void 0) { min = 0; }
  10598. if (max === void 0) { max = 0; }
  10599. if (value === void 0) { value = 0; }
  10600. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10601. if (groupNb < 0 || groupNb >= this._groups.length) {
  10602. return;
  10603. }
  10604. var group = this._groups[groupNb];
  10605. group.addSlider(label, func, unit, min, max, value, onVal);
  10606. };
  10607. return SelectionPanel;
  10608. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10609. /***/ }),
  10610. /***/ "./2D/controls/sliders/baseSlider.ts":
  10611. /*!*******************************************!*\
  10612. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10613. \*******************************************/
  10614. /*! exports provided: BaseSlider */
  10615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10616. "use strict";
  10617. __webpack_require__.r(__webpack_exports__);
  10618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10619. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10620. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10621. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10622. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10623. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10624. /**
  10625. * Class used to create slider controls
  10626. */
  10627. var BaseSlider = /** @class */ (function (_super) {
  10628. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10629. /**
  10630. * Creates a new BaseSlider
  10631. * @param name defines the control name
  10632. */
  10633. function BaseSlider(name) {
  10634. var _this = _super.call(this, name) || this;
  10635. _this.name = name;
  10636. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10637. _this._minimum = 0;
  10638. _this._maximum = 100;
  10639. _this._value = 50;
  10640. _this._isVertical = false;
  10641. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10642. _this._isThumbClamped = false;
  10643. _this._displayThumb = true;
  10644. _this._step = 0;
  10645. _this._lastPointerDownID = -1;
  10646. // Shared rendering info
  10647. _this._effectiveBarOffset = 0;
  10648. /** Observable raised when the sldier value changes */
  10649. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10650. // Events
  10651. _this._pointerIsDown = false;
  10652. _this.isPointerBlocker = true;
  10653. return _this;
  10654. }
  10655. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10656. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10657. get: function () {
  10658. return this._displayThumb;
  10659. },
  10660. set: function (value) {
  10661. if (this._displayThumb === value) {
  10662. return;
  10663. }
  10664. this._displayThumb = value;
  10665. this._markAsDirty();
  10666. },
  10667. enumerable: false,
  10668. configurable: true
  10669. });
  10670. Object.defineProperty(BaseSlider.prototype, "step", {
  10671. /** Gets or sets a step to apply to values (0 by default) */
  10672. get: function () {
  10673. return this._step;
  10674. },
  10675. set: function (value) {
  10676. if (this._step === value) {
  10677. return;
  10678. }
  10679. this._step = value;
  10680. this._markAsDirty();
  10681. },
  10682. enumerable: false,
  10683. configurable: true
  10684. });
  10685. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10686. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10687. get: function () {
  10688. return this._barOffset.toString(this._host);
  10689. },
  10690. set: function (value) {
  10691. if (this._barOffset.toString(this._host) === value) {
  10692. return;
  10693. }
  10694. if (this._barOffset.fromString(value)) {
  10695. this._markAsDirty();
  10696. }
  10697. },
  10698. enumerable: false,
  10699. configurable: true
  10700. });
  10701. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10702. /** Gets main bar offset in pixels*/
  10703. get: function () {
  10704. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10705. },
  10706. enumerable: false,
  10707. configurable: true
  10708. });
  10709. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10710. /** Gets or sets thumb width */
  10711. get: function () {
  10712. return this._thumbWidth.toString(this._host);
  10713. },
  10714. set: function (value) {
  10715. if (this._thumbWidth.toString(this._host) === value) {
  10716. return;
  10717. }
  10718. if (this._thumbWidth.fromString(value)) {
  10719. this._markAsDirty();
  10720. }
  10721. },
  10722. enumerable: false,
  10723. configurable: true
  10724. });
  10725. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10726. /** Gets thumb width in pixels */
  10727. get: function () {
  10728. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10729. },
  10730. enumerable: false,
  10731. configurable: true
  10732. });
  10733. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10734. /** Gets or sets minimum value */
  10735. get: function () {
  10736. return this._minimum;
  10737. },
  10738. set: function (value) {
  10739. if (this._minimum === value) {
  10740. return;
  10741. }
  10742. this._minimum = value;
  10743. this._markAsDirty();
  10744. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10745. },
  10746. enumerable: false,
  10747. configurable: true
  10748. });
  10749. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10750. /** Gets or sets maximum value */
  10751. get: function () {
  10752. return this._maximum;
  10753. },
  10754. set: function (value) {
  10755. if (this._maximum === value) {
  10756. return;
  10757. }
  10758. this._maximum = value;
  10759. this._markAsDirty();
  10760. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10761. },
  10762. enumerable: false,
  10763. configurable: true
  10764. });
  10765. Object.defineProperty(BaseSlider.prototype, "value", {
  10766. /** Gets or sets current value */
  10767. get: function () {
  10768. return this._value;
  10769. },
  10770. set: function (value) {
  10771. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10772. if (this._value === value) {
  10773. return;
  10774. }
  10775. this._value = value;
  10776. this._markAsDirty();
  10777. this.onValueChangedObservable.notifyObservers(this._value);
  10778. },
  10779. enumerable: false,
  10780. configurable: true
  10781. });
  10782. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10783. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10784. get: function () {
  10785. return this._isVertical;
  10786. },
  10787. set: function (value) {
  10788. if (this._isVertical === value) {
  10789. return;
  10790. }
  10791. this._isVertical = value;
  10792. this._markAsDirty();
  10793. },
  10794. enumerable: false,
  10795. configurable: true
  10796. });
  10797. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10798. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10799. get: function () {
  10800. return this._isThumbClamped;
  10801. },
  10802. set: function (value) {
  10803. if (this._isThumbClamped === value) {
  10804. return;
  10805. }
  10806. this._isThumbClamped = value;
  10807. this._markAsDirty();
  10808. },
  10809. enumerable: false,
  10810. configurable: true
  10811. });
  10812. BaseSlider.prototype._getTypeName = function () {
  10813. return "BaseSlider";
  10814. };
  10815. BaseSlider.prototype._getThumbPosition = function () {
  10816. if (this.isVertical) {
  10817. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10818. }
  10819. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10820. };
  10821. BaseSlider.prototype._getThumbThickness = function (type) {
  10822. var thumbThickness = 0;
  10823. switch (type) {
  10824. case "circle":
  10825. if (this._thumbWidth.isPixel) {
  10826. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10827. }
  10828. else {
  10829. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10830. }
  10831. break;
  10832. case "rectangle":
  10833. if (this._thumbWidth.isPixel) {
  10834. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10835. }
  10836. else {
  10837. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10838. }
  10839. }
  10840. return thumbThickness;
  10841. };
  10842. BaseSlider.prototype._prepareRenderingData = function (type) {
  10843. // Main bar
  10844. this._effectiveBarOffset = 0;
  10845. this._renderLeft = this._currentMeasure.left;
  10846. this._renderTop = this._currentMeasure.top;
  10847. this._renderWidth = this._currentMeasure.width;
  10848. this._renderHeight = this._currentMeasure.height;
  10849. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10850. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10851. this._effectiveThumbThickness = this._getThumbThickness(type);
  10852. if (this.displayThumb) {
  10853. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10854. }
  10855. //throw error when height is less than width for vertical slider
  10856. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10857. console.error("Height should be greater than width");
  10858. return;
  10859. }
  10860. if (this._barOffset.isPixel) {
  10861. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10862. }
  10863. else {
  10864. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10865. }
  10866. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10867. if (this.isVertical) {
  10868. this._renderLeft += this._effectiveBarOffset;
  10869. if (!this.isThumbClamped && this.displayThumb) {
  10870. this._renderTop += (this._effectiveThumbThickness / 2);
  10871. }
  10872. this._renderHeight = this._backgroundBoxLength;
  10873. this._renderWidth = this._backgroundBoxThickness;
  10874. }
  10875. else {
  10876. this._renderTop += this._effectiveBarOffset;
  10877. if (!this.isThumbClamped && this.displayThumb) {
  10878. this._renderLeft += (this._effectiveThumbThickness / 2);
  10879. }
  10880. this._renderHeight = this._backgroundBoxThickness;
  10881. this._renderWidth = this._backgroundBoxLength;
  10882. }
  10883. };
  10884. /** @hidden */
  10885. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10886. if (this.rotation != 0) {
  10887. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10888. x = this._transformedPosition.x;
  10889. y = this._transformedPosition.y;
  10890. }
  10891. var value;
  10892. if (this._isVertical) {
  10893. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10894. }
  10895. else {
  10896. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10897. }
  10898. var mult = (1 / this._step) | 0;
  10899. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10900. };
  10901. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10902. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10903. return false;
  10904. }
  10905. this._pointerIsDown = true;
  10906. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10907. this._host._capturingControl[pointerId] = this;
  10908. this._lastPointerDownID = pointerId;
  10909. return true;
  10910. };
  10911. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10912. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10913. if (pointerId != this._lastPointerDownID) {
  10914. return;
  10915. }
  10916. if (this._pointerIsDown) {
  10917. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10918. }
  10919. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10920. };
  10921. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10922. this._pointerIsDown = false;
  10923. delete this._host._capturingControl[pointerId];
  10924. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10925. };
  10926. return BaseSlider;
  10927. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10928. /***/ }),
  10929. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10930. /*!*************************************************!*\
  10931. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10932. \*************************************************/
  10933. /*! exports provided: ImageBasedSlider */
  10934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10935. "use strict";
  10936. __webpack_require__.r(__webpack_exports__);
  10937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10938. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10939. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10940. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10941. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10942. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10943. /**
  10944. * Class used to create slider controls based on images
  10945. */
  10946. var ImageBasedSlider = /** @class */ (function (_super) {
  10947. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10948. /**
  10949. * Creates a new ImageBasedSlider
  10950. * @param name defines the control name
  10951. */
  10952. function ImageBasedSlider(name) {
  10953. var _this = _super.call(this, name) || this;
  10954. _this.name = name;
  10955. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10956. return _this;
  10957. }
  10958. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10959. get: function () {
  10960. return this._displayThumb && this.thumbImage != null;
  10961. },
  10962. set: function (value) {
  10963. if (this._displayThumb === value) {
  10964. return;
  10965. }
  10966. this._displayThumb = value;
  10967. this._markAsDirty();
  10968. },
  10969. enumerable: false,
  10970. configurable: true
  10971. });
  10972. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10973. /**
  10974. * Gets or sets the image used to render the background
  10975. */
  10976. get: function () {
  10977. return this._backgroundImage;
  10978. },
  10979. set: function (value) {
  10980. var _this = this;
  10981. if (this._backgroundImage === value) {
  10982. return;
  10983. }
  10984. this._backgroundImage = value;
  10985. if (value && !value.isLoaded) {
  10986. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10987. }
  10988. this._markAsDirty();
  10989. },
  10990. enumerable: false,
  10991. configurable: true
  10992. });
  10993. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10994. /**
  10995. * Gets or sets the image used to render the value bar
  10996. */
  10997. get: function () {
  10998. return this._valueBarImage;
  10999. },
  11000. set: function (value) {
  11001. var _this = this;
  11002. if (this._valueBarImage === value) {
  11003. return;
  11004. }
  11005. this._valueBarImage = value;
  11006. if (value && !value.isLoaded) {
  11007. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11008. }
  11009. this._markAsDirty();
  11010. },
  11011. enumerable: false,
  11012. configurable: true
  11013. });
  11014. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11015. /**
  11016. * Gets or sets the image used to render the thumb
  11017. */
  11018. get: function () {
  11019. return this._thumbImage;
  11020. },
  11021. set: function (value) {
  11022. var _this = this;
  11023. if (this._thumbImage === value) {
  11024. return;
  11025. }
  11026. this._thumbImage = value;
  11027. if (value && !value.isLoaded) {
  11028. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11029. }
  11030. this._markAsDirty();
  11031. },
  11032. enumerable: false,
  11033. configurable: true
  11034. });
  11035. ImageBasedSlider.prototype._getTypeName = function () {
  11036. return "ImageBasedSlider";
  11037. };
  11038. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11039. context.save();
  11040. this._applyStates(context);
  11041. this._prepareRenderingData("rectangle");
  11042. var thumbPosition = this._getThumbPosition();
  11043. var left = this._renderLeft;
  11044. var top = this._renderTop;
  11045. var width = this._renderWidth;
  11046. var height = this._renderHeight;
  11047. // Background
  11048. if (this._backgroundImage) {
  11049. this._tempMeasure.copyFromFloats(left, top, width, height);
  11050. if (this.isThumbClamped && this.displayThumb) {
  11051. if (this.isVertical) {
  11052. this._tempMeasure.height += this._effectiveThumbThickness;
  11053. }
  11054. else {
  11055. this._tempMeasure.width += this._effectiveThumbThickness;
  11056. }
  11057. }
  11058. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11059. this._backgroundImage._draw(context);
  11060. }
  11061. // Bar
  11062. if (this._valueBarImage) {
  11063. if (this.isVertical) {
  11064. if (this.isThumbClamped && this.displayThumb) {
  11065. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11066. }
  11067. else {
  11068. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11069. }
  11070. }
  11071. else {
  11072. if (this.isThumbClamped && this.displayThumb) {
  11073. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11074. }
  11075. else {
  11076. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11077. }
  11078. }
  11079. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11080. this._valueBarImage._draw(context);
  11081. }
  11082. // Thumb
  11083. if (this.displayThumb) {
  11084. if (this.isVertical) {
  11085. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11086. }
  11087. else {
  11088. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11089. }
  11090. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11091. this._thumbImage._draw(context);
  11092. }
  11093. context.restore();
  11094. };
  11095. return ImageBasedSlider;
  11096. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11097. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11098. /***/ }),
  11099. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11100. /*!***********************************************!*\
  11101. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11102. \***********************************************/
  11103. /*! exports provided: ImageScrollBar */
  11104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11105. "use strict";
  11106. __webpack_require__.r(__webpack_exports__);
  11107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11108. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11109. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11110. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11111. /**
  11112. * Class used to create slider controls
  11113. */
  11114. var ImageScrollBar = /** @class */ (function (_super) {
  11115. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11116. /**
  11117. * Creates a new ImageScrollBar
  11118. * @param name defines the control name
  11119. */
  11120. function ImageScrollBar(name) {
  11121. var _this = _super.call(this, name) || this;
  11122. _this.name = name;
  11123. _this._thumbLength = 0.5;
  11124. _this._thumbHeight = 1;
  11125. _this._barImageHeight = 1;
  11126. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11127. /** Number of 90° rotation to apply on the images when in vertical mode */
  11128. _this.num90RotationInVerticalMode = 1;
  11129. return _this;
  11130. }
  11131. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11132. /**
  11133. * Gets or sets the image used to render the background for horizontal bar
  11134. */
  11135. get: function () {
  11136. return this._backgroundBaseImage;
  11137. },
  11138. set: function (value) {
  11139. var _this = this;
  11140. if (this._backgroundBaseImage === value) {
  11141. return;
  11142. }
  11143. this._backgroundBaseImage = value;
  11144. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11145. if (!value.isLoaded) {
  11146. value.onImageLoadedObservable.addOnce(function () {
  11147. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11148. _this._backgroundImage = rotatedValue;
  11149. if (!rotatedValue.isLoaded) {
  11150. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11151. _this._markAsDirty();
  11152. });
  11153. }
  11154. _this._markAsDirty();
  11155. });
  11156. }
  11157. else {
  11158. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11159. this._markAsDirty();
  11160. }
  11161. }
  11162. else {
  11163. this._backgroundImage = value;
  11164. if (value && !value.isLoaded) {
  11165. value.onImageLoadedObservable.addOnce(function () {
  11166. _this._markAsDirty();
  11167. });
  11168. }
  11169. this._markAsDirty();
  11170. }
  11171. },
  11172. enumerable: false,
  11173. configurable: true
  11174. });
  11175. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11176. /**
  11177. * Gets or sets the image used to render the thumb
  11178. */
  11179. get: function () {
  11180. return this._thumbBaseImage;
  11181. },
  11182. set: function (value) {
  11183. var _this = this;
  11184. if (this._thumbBaseImage === value) {
  11185. return;
  11186. }
  11187. this._thumbBaseImage = value;
  11188. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11189. if (!value.isLoaded) {
  11190. value.onImageLoadedObservable.addOnce(function () {
  11191. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11192. _this._thumbImage = rotatedValue;
  11193. if (!rotatedValue.isLoaded) {
  11194. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11195. _this._markAsDirty();
  11196. });
  11197. }
  11198. _this._markAsDirty();
  11199. });
  11200. }
  11201. else {
  11202. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11203. this._markAsDirty();
  11204. }
  11205. }
  11206. else {
  11207. this._thumbImage = value;
  11208. if (value && !value.isLoaded) {
  11209. value.onImageLoadedObservable.addOnce(function () {
  11210. _this._markAsDirty();
  11211. });
  11212. }
  11213. this._markAsDirty();
  11214. }
  11215. },
  11216. enumerable: false,
  11217. configurable: true
  11218. });
  11219. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11220. /**
  11221. * Gets or sets the length of the thumb
  11222. */
  11223. get: function () {
  11224. return this._thumbLength;
  11225. },
  11226. set: function (value) {
  11227. if (this._thumbLength === value) {
  11228. return;
  11229. }
  11230. this._thumbLength = value;
  11231. this._markAsDirty();
  11232. },
  11233. enumerable: false,
  11234. configurable: true
  11235. });
  11236. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11237. /**
  11238. * Gets or sets the height of the thumb
  11239. */
  11240. get: function () {
  11241. return this._thumbHeight;
  11242. },
  11243. set: function (value) {
  11244. if (this._thumbLength === value) {
  11245. return;
  11246. }
  11247. this._thumbHeight = value;
  11248. this._markAsDirty();
  11249. },
  11250. enumerable: false,
  11251. configurable: true
  11252. });
  11253. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11254. /**
  11255. * Gets or sets the height of the bar image
  11256. */
  11257. get: function () {
  11258. return this._barImageHeight;
  11259. },
  11260. set: function (value) {
  11261. if (this._barImageHeight === value) {
  11262. return;
  11263. }
  11264. this._barImageHeight = value;
  11265. this._markAsDirty();
  11266. },
  11267. enumerable: false,
  11268. configurable: true
  11269. });
  11270. ImageScrollBar.prototype._getTypeName = function () {
  11271. return "ImageScrollBar";
  11272. };
  11273. ImageScrollBar.prototype._getThumbThickness = function () {
  11274. var thumbThickness = 0;
  11275. if (this._thumbWidth.isPixel) {
  11276. thumbThickness = this._thumbWidth.getValue(this._host);
  11277. }
  11278. else {
  11279. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11280. }
  11281. return thumbThickness;
  11282. };
  11283. ImageScrollBar.prototype._draw = function (context) {
  11284. context.save();
  11285. this._applyStates(context);
  11286. this._prepareRenderingData("rectangle");
  11287. var thumbPosition = this._getThumbPosition();
  11288. var left = this._renderLeft;
  11289. var top = this._renderTop;
  11290. var width = this._renderWidth;
  11291. var height = this._renderHeight;
  11292. // Background
  11293. if (this._backgroundImage) {
  11294. this._tempMeasure.copyFromFloats(left, top, width, height);
  11295. if (this.isVertical) {
  11296. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11297. this._tempMeasure.height += this._effectiveThumbThickness;
  11298. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11299. }
  11300. else {
  11301. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11302. this._tempMeasure.width += this._effectiveThumbThickness;
  11303. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11304. }
  11305. this._backgroundImage._draw(context);
  11306. }
  11307. // Thumb
  11308. if (this.isVertical) {
  11309. 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);
  11310. }
  11311. else {
  11312. 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);
  11313. }
  11314. if (this._thumbImage) {
  11315. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11316. this._thumbImage._draw(context);
  11317. }
  11318. context.restore();
  11319. };
  11320. /** @hidden */
  11321. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11322. if (this.rotation != 0) {
  11323. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11324. x = this._transformedPosition.x;
  11325. y = this._transformedPosition.y;
  11326. }
  11327. if (this._first) {
  11328. this._first = false;
  11329. this._originX = x;
  11330. this._originY = y;
  11331. // Check if move is required
  11332. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11333. if (this.isVertical) {
  11334. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11335. }
  11336. else {
  11337. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11338. }
  11339. }
  11340. }
  11341. // Delta mode
  11342. var delta = 0;
  11343. if (this.isVertical) {
  11344. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11345. }
  11346. else {
  11347. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11348. }
  11349. this.value += delta * (this.maximum - this.minimum);
  11350. this._originX = x;
  11351. this._originY = y;
  11352. };
  11353. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11354. this._first = true;
  11355. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11356. };
  11357. return ImageScrollBar;
  11358. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11359. /***/ }),
  11360. /***/ "./2D/controls/sliders/scrollBar.ts":
  11361. /*!******************************************!*\
  11362. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11363. \******************************************/
  11364. /*! exports provided: ScrollBar */
  11365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11366. "use strict";
  11367. __webpack_require__.r(__webpack_exports__);
  11368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11369. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11370. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11371. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11372. /**
  11373. * Class used to create slider controls
  11374. */
  11375. var ScrollBar = /** @class */ (function (_super) {
  11376. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11377. /**
  11378. * Creates a new Slider
  11379. * @param name defines the control name
  11380. */
  11381. function ScrollBar(name) {
  11382. var _this = _super.call(this, name) || this;
  11383. _this.name = name;
  11384. _this._background = "black";
  11385. _this._borderColor = "white";
  11386. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11387. return _this;
  11388. }
  11389. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11390. /** Gets or sets border color */
  11391. get: function () {
  11392. return this._borderColor;
  11393. },
  11394. set: function (value) {
  11395. if (this._borderColor === value) {
  11396. return;
  11397. }
  11398. this._borderColor = value;
  11399. this._markAsDirty();
  11400. },
  11401. enumerable: false,
  11402. configurable: true
  11403. });
  11404. Object.defineProperty(ScrollBar.prototype, "background", {
  11405. /** Gets or sets background color */
  11406. get: function () {
  11407. return this._background;
  11408. },
  11409. set: function (value) {
  11410. if (this._background === value) {
  11411. return;
  11412. }
  11413. this._background = value;
  11414. this._markAsDirty();
  11415. },
  11416. enumerable: false,
  11417. configurable: true
  11418. });
  11419. ScrollBar.prototype._getTypeName = function () {
  11420. return "Scrollbar";
  11421. };
  11422. ScrollBar.prototype._getThumbThickness = function () {
  11423. var thumbThickness = 0;
  11424. if (this._thumbWidth.isPixel) {
  11425. thumbThickness = this._thumbWidth.getValue(this._host);
  11426. }
  11427. else {
  11428. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11429. }
  11430. return thumbThickness;
  11431. };
  11432. ScrollBar.prototype._draw = function (context) {
  11433. context.save();
  11434. this._applyStates(context);
  11435. this._prepareRenderingData("rectangle");
  11436. var left = this._renderLeft;
  11437. var thumbPosition = this._getThumbPosition();
  11438. context.fillStyle = this._background;
  11439. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11440. // Value bar
  11441. context.fillStyle = this.color;
  11442. // Thumb
  11443. if (this.isVertical) {
  11444. this._tempMeasure.left = left - this._effectiveBarOffset;
  11445. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11446. this._tempMeasure.width = this._currentMeasure.width;
  11447. this._tempMeasure.height = this._effectiveThumbThickness;
  11448. }
  11449. else {
  11450. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11451. this._tempMeasure.top = this._currentMeasure.top;
  11452. this._tempMeasure.width = this._effectiveThumbThickness;
  11453. this._tempMeasure.height = this._currentMeasure.height;
  11454. }
  11455. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11456. context.restore();
  11457. };
  11458. /** @hidden */
  11459. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11460. if (this.rotation != 0) {
  11461. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11462. x = this._transformedPosition.x;
  11463. y = this._transformedPosition.y;
  11464. }
  11465. if (this._first) {
  11466. this._first = false;
  11467. this._originX = x;
  11468. this._originY = y;
  11469. // Check if move is required
  11470. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11471. if (this.isVertical) {
  11472. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11473. }
  11474. else {
  11475. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11476. }
  11477. }
  11478. }
  11479. // Delta mode
  11480. var delta = 0;
  11481. if (this.isVertical) {
  11482. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11483. }
  11484. else {
  11485. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11486. }
  11487. this.value += delta * (this.maximum - this.minimum);
  11488. this._originX = x;
  11489. this._originY = y;
  11490. };
  11491. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11492. this._first = true;
  11493. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11494. };
  11495. return ScrollBar;
  11496. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11497. /***/ }),
  11498. /***/ "./2D/controls/sliders/slider.ts":
  11499. /*!***************************************!*\
  11500. !*** ./2D/controls/sliders/slider.ts ***!
  11501. \***************************************/
  11502. /*! exports provided: Slider */
  11503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11504. "use strict";
  11505. __webpack_require__.r(__webpack_exports__);
  11506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11507. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11508. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11509. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11510. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11511. /**
  11512. * Class used to create slider controls
  11513. */
  11514. var Slider = /** @class */ (function (_super) {
  11515. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11516. /**
  11517. * Creates a new Slider
  11518. * @param name defines the control name
  11519. */
  11520. function Slider(name) {
  11521. var _this = _super.call(this, name) || this;
  11522. _this.name = name;
  11523. _this._background = "black";
  11524. _this._borderColor = "white";
  11525. _this._isThumbCircle = false;
  11526. _this._displayValueBar = true;
  11527. return _this;
  11528. }
  11529. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11530. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11531. get: function () {
  11532. return this._displayValueBar;
  11533. },
  11534. set: function (value) {
  11535. if (this._displayValueBar === value) {
  11536. return;
  11537. }
  11538. this._displayValueBar = value;
  11539. this._markAsDirty();
  11540. },
  11541. enumerable: false,
  11542. configurable: true
  11543. });
  11544. Object.defineProperty(Slider.prototype, "borderColor", {
  11545. /** Gets or sets border color */
  11546. get: function () {
  11547. return this._borderColor;
  11548. },
  11549. set: function (value) {
  11550. if (this._borderColor === value) {
  11551. return;
  11552. }
  11553. this._borderColor = value;
  11554. this._markAsDirty();
  11555. },
  11556. enumerable: false,
  11557. configurable: true
  11558. });
  11559. Object.defineProperty(Slider.prototype, "background", {
  11560. /** Gets or sets background color */
  11561. get: function () {
  11562. return this._background;
  11563. },
  11564. set: function (value) {
  11565. if (this._background === value) {
  11566. return;
  11567. }
  11568. this._background = value;
  11569. this._markAsDirty();
  11570. },
  11571. enumerable: false,
  11572. configurable: true
  11573. });
  11574. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11575. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11576. get: function () {
  11577. return this._isThumbCircle;
  11578. },
  11579. set: function (value) {
  11580. if (this._isThumbCircle === value) {
  11581. return;
  11582. }
  11583. this._isThumbCircle = value;
  11584. this._markAsDirty();
  11585. },
  11586. enumerable: false,
  11587. configurable: true
  11588. });
  11589. Slider.prototype._getTypeName = function () {
  11590. return "Slider";
  11591. };
  11592. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11593. context.save();
  11594. this._applyStates(context);
  11595. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11596. var left = this._renderLeft;
  11597. var top = this._renderTop;
  11598. var width = this._renderWidth;
  11599. var height = this._renderHeight;
  11600. var radius = 0;
  11601. if (this.isThumbClamped && this.isThumbCircle) {
  11602. if (this.isVertical) {
  11603. top += (this._effectiveThumbThickness / 2);
  11604. }
  11605. else {
  11606. left += (this._effectiveThumbThickness / 2);
  11607. }
  11608. radius = this._backgroundBoxThickness / 2;
  11609. }
  11610. else {
  11611. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11612. }
  11613. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11614. context.shadowColor = this.shadowColor;
  11615. context.shadowBlur = this.shadowBlur;
  11616. context.shadowOffsetX = this.shadowOffsetX;
  11617. context.shadowOffsetY = this.shadowOffsetY;
  11618. }
  11619. var thumbPosition = this._getThumbPosition();
  11620. context.fillStyle = this._background;
  11621. if (this.isVertical) {
  11622. if (this.isThumbClamped) {
  11623. if (this.isThumbCircle) {
  11624. context.beginPath();
  11625. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11626. context.fill();
  11627. context.fillRect(left, top, width, height);
  11628. }
  11629. else {
  11630. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11631. }
  11632. }
  11633. else {
  11634. context.fillRect(left, top, width, height);
  11635. }
  11636. }
  11637. else {
  11638. if (this.isThumbClamped) {
  11639. if (this.isThumbCircle) {
  11640. context.beginPath();
  11641. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11642. context.fill();
  11643. context.fillRect(left, top, width, height);
  11644. }
  11645. else {
  11646. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11647. }
  11648. }
  11649. else {
  11650. context.fillRect(left, top, width, height);
  11651. }
  11652. }
  11653. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11654. context.shadowBlur = 0;
  11655. context.shadowOffsetX = 0;
  11656. context.shadowOffsetY = 0;
  11657. }
  11658. // Value bar
  11659. context.fillStyle = this.color;
  11660. if (this._displayValueBar) {
  11661. if (this.isVertical) {
  11662. if (this.isThumbClamped) {
  11663. if (this.isThumbCircle) {
  11664. context.beginPath();
  11665. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11666. context.fill();
  11667. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11668. }
  11669. else {
  11670. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11671. }
  11672. }
  11673. else {
  11674. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11675. }
  11676. }
  11677. else {
  11678. if (this.isThumbClamped) {
  11679. if (this.isThumbCircle) {
  11680. context.beginPath();
  11681. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11682. context.fill();
  11683. context.fillRect(left, top, thumbPosition, height);
  11684. }
  11685. else {
  11686. context.fillRect(left, top, thumbPosition, height);
  11687. }
  11688. }
  11689. else {
  11690. context.fillRect(left, top, thumbPosition, height);
  11691. }
  11692. }
  11693. }
  11694. // Thumb
  11695. if (this.displayThumb) {
  11696. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11697. context.shadowColor = this.shadowColor;
  11698. context.shadowBlur = this.shadowBlur;
  11699. context.shadowOffsetX = this.shadowOffsetX;
  11700. context.shadowOffsetY = this.shadowOffsetY;
  11701. }
  11702. if (this._isThumbCircle) {
  11703. context.beginPath();
  11704. if (this.isVertical) {
  11705. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11706. }
  11707. else {
  11708. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11709. }
  11710. context.fill();
  11711. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11712. context.shadowBlur = 0;
  11713. context.shadowOffsetX = 0;
  11714. context.shadowOffsetY = 0;
  11715. }
  11716. context.strokeStyle = this._borderColor;
  11717. context.stroke();
  11718. }
  11719. else {
  11720. if (this.isVertical) {
  11721. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11722. }
  11723. else {
  11724. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11725. }
  11726. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11727. context.shadowBlur = 0;
  11728. context.shadowOffsetX = 0;
  11729. context.shadowOffsetY = 0;
  11730. }
  11731. context.strokeStyle = this._borderColor;
  11732. if (this.isVertical) {
  11733. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11734. }
  11735. else {
  11736. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11737. }
  11738. }
  11739. }
  11740. context.restore();
  11741. };
  11742. return Slider;
  11743. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11744. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11745. /***/ }),
  11746. /***/ "./2D/controls/stackPanel.ts":
  11747. /*!***********************************!*\
  11748. !*** ./2D/controls/stackPanel.ts ***!
  11749. \***********************************/
  11750. /*! exports provided: StackPanel */
  11751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11752. "use strict";
  11753. __webpack_require__.r(__webpack_exports__);
  11754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11755. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11756. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11757. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11758. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11759. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11760. /**
  11761. * Class used to create a 2D stack panel container
  11762. */
  11763. var StackPanel = /** @class */ (function (_super) {
  11764. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11765. /**
  11766. * Creates a new StackPanel
  11767. * @param name defines control name
  11768. */
  11769. function StackPanel(name) {
  11770. var _this = _super.call(this, name) || this;
  11771. _this.name = name;
  11772. _this._isVertical = true;
  11773. _this._manualWidth = false;
  11774. _this._manualHeight = false;
  11775. _this._doNotTrackManualChanges = false;
  11776. /**
  11777. * Gets or sets a boolean indicating that layou warnings should be ignored
  11778. */
  11779. _this.ignoreLayoutWarnings = false;
  11780. return _this;
  11781. }
  11782. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11783. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11784. get: function () {
  11785. return this._isVertical;
  11786. },
  11787. set: function (value) {
  11788. if (this._isVertical === value) {
  11789. return;
  11790. }
  11791. this._isVertical = value;
  11792. this._markAsDirty();
  11793. },
  11794. enumerable: false,
  11795. configurable: true
  11796. });
  11797. Object.defineProperty(StackPanel.prototype, "width", {
  11798. get: function () {
  11799. return this._width.toString(this._host);
  11800. },
  11801. /**
  11802. * Gets or sets panel width.
  11803. * This value should not be set when in horizontal mode as it will be computed automatically
  11804. */
  11805. set: function (value) {
  11806. if (!this._doNotTrackManualChanges) {
  11807. this._manualWidth = true;
  11808. }
  11809. if (this._width.toString(this._host) === value) {
  11810. return;
  11811. }
  11812. if (this._width.fromString(value)) {
  11813. this._markAsDirty();
  11814. }
  11815. },
  11816. enumerable: false,
  11817. configurable: true
  11818. });
  11819. Object.defineProperty(StackPanel.prototype, "height", {
  11820. get: function () {
  11821. return this._height.toString(this._host);
  11822. },
  11823. /**
  11824. * Gets or sets panel height.
  11825. * This value should not be set when in vertical mode as it will be computed automatically
  11826. */
  11827. set: function (value) {
  11828. if (!this._doNotTrackManualChanges) {
  11829. this._manualHeight = true;
  11830. }
  11831. if (this._height.toString(this._host) === value) {
  11832. return;
  11833. }
  11834. if (this._height.fromString(value)) {
  11835. this._markAsDirty();
  11836. }
  11837. },
  11838. enumerable: false,
  11839. configurable: true
  11840. });
  11841. StackPanel.prototype._getTypeName = function () {
  11842. return "StackPanel";
  11843. };
  11844. /** @hidden */
  11845. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11846. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11847. var child = _a[_i];
  11848. if (this._isVertical) {
  11849. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11850. }
  11851. else {
  11852. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11853. }
  11854. }
  11855. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11856. };
  11857. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11858. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11859. this._measureForChildren.copyFrom(parentMeasure);
  11860. this._measureForChildren.left = this._currentMeasure.left;
  11861. this._measureForChildren.top = this._currentMeasure.top;
  11862. if (!this.isVertical || this._manualWidth) {
  11863. this._measureForChildren.width = this._currentMeasure.width;
  11864. }
  11865. if (this.isVertical || this._manualHeight) {
  11866. this._measureForChildren.height = this._currentMeasure.height;
  11867. }
  11868. };
  11869. StackPanel.prototype._postMeasure = function () {
  11870. var stackWidth = 0;
  11871. var stackHeight = 0;
  11872. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11873. var child = _a[_i];
  11874. if (!child.isVisible || child.notRenderable) {
  11875. continue;
  11876. }
  11877. if (this._isVertical) {
  11878. if (child.top !== stackHeight + "px") {
  11879. child.top = stackHeight + "px";
  11880. this._rebuildLayout = true;
  11881. child._top.ignoreAdaptiveScaling = true;
  11882. }
  11883. if (child._height.isPercentage && !child._automaticSize) {
  11884. if (!this.ignoreLayoutWarnings) {
  11885. 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");
  11886. }
  11887. }
  11888. else {
  11889. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11890. }
  11891. }
  11892. else {
  11893. if (child.left !== stackWidth + "px") {
  11894. child.left = stackWidth + "px";
  11895. this._rebuildLayout = true;
  11896. child._left.ignoreAdaptiveScaling = true;
  11897. }
  11898. if (child._width.isPercentage && !child._automaticSize) {
  11899. if (!this.ignoreLayoutWarnings) {
  11900. 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");
  11901. }
  11902. }
  11903. else {
  11904. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11905. }
  11906. }
  11907. }
  11908. this._doNotTrackManualChanges = true;
  11909. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11910. // User can now define their own height and width for stack panel.
  11911. var panelWidthChanged = false;
  11912. var panelHeightChanged = false;
  11913. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11914. var previousHeight = this.height;
  11915. this.height = stackHeight + "px";
  11916. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11917. }
  11918. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11919. var previousWidth = this.width;
  11920. this.width = stackWidth + "px";
  11921. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11922. }
  11923. if (panelHeightChanged) {
  11924. this._height.ignoreAdaptiveScaling = true;
  11925. }
  11926. if (panelWidthChanged) {
  11927. this._width.ignoreAdaptiveScaling = true;
  11928. }
  11929. this._doNotTrackManualChanges = false;
  11930. if (panelWidthChanged || panelHeightChanged) {
  11931. this._rebuildLayout = true;
  11932. }
  11933. _super.prototype._postMeasure.call(this);
  11934. };
  11935. return StackPanel;
  11936. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11937. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11938. /***/ }),
  11939. /***/ "./2D/controls/statics.ts":
  11940. /*!********************************!*\
  11941. !*** ./2D/controls/statics.ts ***!
  11942. \********************************/
  11943. /*! exports provided: name */
  11944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11945. "use strict";
  11946. __webpack_require__.r(__webpack_exports__);
  11947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11948. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11949. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11950. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11951. /**
  11952. * Forcing an export so that this code will execute
  11953. * @hidden
  11954. */
  11955. var name = "Statics";
  11956. /**
  11957. * Creates a stack panel that can be used to render headers
  11958. * @param control defines the control to associate with the header
  11959. * @param text defines the text of the header
  11960. * @param size defines the size of the header
  11961. * @param options defines options used to configure the header
  11962. * @returns a new StackPanel
  11963. */
  11964. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11965. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11966. var isHorizontal = options ? options.isHorizontal : true;
  11967. var controlFirst = options ? options.controlFirst : true;
  11968. panel.isVertical = !isHorizontal;
  11969. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11970. header.text = text;
  11971. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11972. if (isHorizontal) {
  11973. header.width = size;
  11974. }
  11975. else {
  11976. header.height = size;
  11977. }
  11978. if (controlFirst) {
  11979. panel.addControl(control);
  11980. panel.addControl(header);
  11981. header.paddingLeft = "5px";
  11982. }
  11983. else {
  11984. panel.addControl(header);
  11985. panel.addControl(control);
  11986. header.paddingRight = "5px";
  11987. }
  11988. header.shadowBlur = control.shadowBlur;
  11989. header.shadowColor = control.shadowColor;
  11990. header.shadowOffsetX = control.shadowOffsetX;
  11991. header.shadowOffsetY = control.shadowOffsetY;
  11992. return panel;
  11993. };
  11994. /***/ }),
  11995. /***/ "./2D/controls/textBlock.ts":
  11996. /*!**********************************!*\
  11997. !*** ./2D/controls/textBlock.ts ***!
  11998. \**********************************/
  11999. /*! exports provided: TextWrapping, TextBlock */
  12000. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12001. "use strict";
  12002. __webpack_require__.r(__webpack_exports__);
  12003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12005. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12006. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12007. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12008. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12009. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12010. /**
  12011. * Enum that determines the text-wrapping mode to use.
  12012. */
  12013. var TextWrapping;
  12014. (function (TextWrapping) {
  12015. /**
  12016. * Clip the text when it's larger than Control.width; this is the default mode.
  12017. */
  12018. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12019. /**
  12020. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12021. */
  12022. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12023. /**
  12024. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12025. */
  12026. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12027. })(TextWrapping || (TextWrapping = {}));
  12028. /**
  12029. * Class used to create text block control
  12030. */
  12031. var TextBlock = /** @class */ (function (_super) {
  12032. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12033. /**
  12034. * Creates a new TextBlock object
  12035. * @param name defines the name of the control
  12036. * @param text defines the text to display (emptry string by default)
  12037. */
  12038. function TextBlock(
  12039. /**
  12040. * Defines the name of the control
  12041. */
  12042. name, text) {
  12043. if (text === void 0) { text = ""; }
  12044. var _this = _super.call(this, name) || this;
  12045. _this.name = name;
  12046. _this._text = "";
  12047. _this._textWrapping = TextWrapping.Clip;
  12048. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12049. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12050. _this._resizeToFit = false;
  12051. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12052. _this._outlineWidth = 0;
  12053. _this._outlineColor = "white";
  12054. /**
  12055. * An event triggered after the text is changed
  12056. */
  12057. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12058. /**
  12059. * An event triggered after the text was broken up into lines
  12060. */
  12061. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12062. _this.text = text;
  12063. return _this;
  12064. }
  12065. Object.defineProperty(TextBlock.prototype, "lines", {
  12066. /**
  12067. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12068. */
  12069. get: function () {
  12070. return this._lines;
  12071. },
  12072. enumerable: false,
  12073. configurable: true
  12074. });
  12075. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12076. /**
  12077. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12078. */
  12079. get: function () {
  12080. return this._resizeToFit;
  12081. },
  12082. /**
  12083. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12084. */
  12085. set: function (value) {
  12086. if (this._resizeToFit === value) {
  12087. return;
  12088. }
  12089. this._resizeToFit = value;
  12090. if (this._resizeToFit) {
  12091. this._width.ignoreAdaptiveScaling = true;
  12092. this._height.ignoreAdaptiveScaling = true;
  12093. }
  12094. this._markAsDirty();
  12095. },
  12096. enumerable: false,
  12097. configurable: true
  12098. });
  12099. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12100. /**
  12101. * Gets or sets a boolean indicating if text must be wrapped
  12102. */
  12103. get: function () {
  12104. return this._textWrapping;
  12105. },
  12106. /**
  12107. * Gets or sets a boolean indicating if text must be wrapped
  12108. */
  12109. set: function (value) {
  12110. if (this._textWrapping === value) {
  12111. return;
  12112. }
  12113. this._textWrapping = +value;
  12114. this._markAsDirty();
  12115. },
  12116. enumerable: false,
  12117. configurable: true
  12118. });
  12119. Object.defineProperty(TextBlock.prototype, "text", {
  12120. /**
  12121. * Gets or sets text to display
  12122. */
  12123. get: function () {
  12124. return this._text;
  12125. },
  12126. /**
  12127. * Gets or sets text to display
  12128. */
  12129. set: function (value) {
  12130. if (this._text === value) {
  12131. return;
  12132. }
  12133. this._text = value;
  12134. this._markAsDirty();
  12135. this.onTextChangedObservable.notifyObservers(this);
  12136. },
  12137. enumerable: false,
  12138. configurable: true
  12139. });
  12140. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12141. /**
  12142. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12143. */
  12144. get: function () {
  12145. return this._textHorizontalAlignment;
  12146. },
  12147. /**
  12148. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12149. */
  12150. set: function (value) {
  12151. if (this._textHorizontalAlignment === value) {
  12152. return;
  12153. }
  12154. this._textHorizontalAlignment = value;
  12155. this._markAsDirty();
  12156. },
  12157. enumerable: false,
  12158. configurable: true
  12159. });
  12160. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12161. /**
  12162. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12163. */
  12164. get: function () {
  12165. return this._textVerticalAlignment;
  12166. },
  12167. /**
  12168. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12169. */
  12170. set: function (value) {
  12171. if (this._textVerticalAlignment === value) {
  12172. return;
  12173. }
  12174. this._textVerticalAlignment = value;
  12175. this._markAsDirty();
  12176. },
  12177. enumerable: false,
  12178. configurable: true
  12179. });
  12180. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12181. /**
  12182. * Gets or sets line spacing value
  12183. */
  12184. get: function () {
  12185. return this._lineSpacing.toString(this._host);
  12186. },
  12187. /**
  12188. * Gets or sets line spacing value
  12189. */
  12190. set: function (value) {
  12191. if (this._lineSpacing.fromString(value)) {
  12192. this._markAsDirty();
  12193. }
  12194. },
  12195. enumerable: false,
  12196. configurable: true
  12197. });
  12198. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12199. /**
  12200. * Gets or sets outlineWidth of the text to display
  12201. */
  12202. get: function () {
  12203. return this._outlineWidth;
  12204. },
  12205. /**
  12206. * Gets or sets outlineWidth of the text to display
  12207. */
  12208. set: function (value) {
  12209. if (this._outlineWidth === value) {
  12210. return;
  12211. }
  12212. this._outlineWidth = value;
  12213. this._markAsDirty();
  12214. },
  12215. enumerable: false,
  12216. configurable: true
  12217. });
  12218. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12219. /**
  12220. * Gets or sets outlineColor of the text to display
  12221. */
  12222. get: function () {
  12223. return this._outlineColor;
  12224. },
  12225. /**
  12226. * Gets or sets outlineColor of the text to display
  12227. */
  12228. set: function (value) {
  12229. if (this._outlineColor === value) {
  12230. return;
  12231. }
  12232. this._outlineColor = value;
  12233. this._markAsDirty();
  12234. },
  12235. enumerable: false,
  12236. configurable: true
  12237. });
  12238. TextBlock.prototype._getTypeName = function () {
  12239. return "TextBlock";
  12240. };
  12241. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12242. if (!this._fontOffset) {
  12243. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12244. }
  12245. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12246. // Prepare lines
  12247. this._lines = this._breakLines(this._currentMeasure.width, context);
  12248. this.onLinesReadyObservable.notifyObservers(this);
  12249. var maxLineWidth = 0;
  12250. for (var i = 0; i < this._lines.length; i++) {
  12251. var line = this._lines[i];
  12252. if (line.width > maxLineWidth) {
  12253. maxLineWidth = line.width;
  12254. }
  12255. }
  12256. if (this._resizeToFit) {
  12257. if (this._textWrapping === TextWrapping.Clip) {
  12258. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12259. if (newWidth !== this._width.internalValue) {
  12260. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12261. this._rebuildLayout = true;
  12262. }
  12263. }
  12264. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12265. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12266. var lineSpacing = 0;
  12267. if (this._lineSpacing.isPixel) {
  12268. lineSpacing = this._lineSpacing.getValue(this._host);
  12269. }
  12270. else {
  12271. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12272. }
  12273. newHeight += (this._lines.length - 1) * lineSpacing;
  12274. }
  12275. if (newHeight !== this._height.internalValue) {
  12276. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12277. this._rebuildLayout = true;
  12278. }
  12279. }
  12280. };
  12281. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12282. var width = this._currentMeasure.width;
  12283. var x = 0;
  12284. switch (this._textHorizontalAlignment) {
  12285. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12286. x = 0;
  12287. break;
  12288. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12289. x = width - textWidth;
  12290. break;
  12291. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12292. x = (width - textWidth) / 2;
  12293. break;
  12294. }
  12295. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12296. context.shadowColor = this.shadowColor;
  12297. context.shadowBlur = this.shadowBlur;
  12298. context.shadowOffsetX = this.shadowOffsetX;
  12299. context.shadowOffsetY = this.shadowOffsetY;
  12300. }
  12301. if (this.outlineWidth) {
  12302. context.strokeText(text, this._currentMeasure.left + x, y);
  12303. }
  12304. context.fillText(text, this._currentMeasure.left + x, y);
  12305. };
  12306. /** @hidden */
  12307. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12308. context.save();
  12309. this._applyStates(context);
  12310. // Render lines
  12311. this._renderLines(context);
  12312. context.restore();
  12313. };
  12314. TextBlock.prototype._applyStates = function (context) {
  12315. _super.prototype._applyStates.call(this, context);
  12316. if (this.outlineWidth) {
  12317. context.lineWidth = this.outlineWidth;
  12318. context.strokeStyle = this.outlineColor;
  12319. }
  12320. };
  12321. TextBlock.prototype._breakLines = function (refWidth, context) {
  12322. var lines = [];
  12323. var _lines = this.text.split("\n");
  12324. if (this._textWrapping === TextWrapping.Ellipsis) {
  12325. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12326. var _line = _lines_1[_i];
  12327. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12328. }
  12329. }
  12330. else if (this._textWrapping === TextWrapping.WordWrap) {
  12331. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12332. var _line = _lines_2[_a];
  12333. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12334. }
  12335. }
  12336. else {
  12337. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12338. var _line = _lines_3[_b];
  12339. lines.push(this._parseLine(_line, context));
  12340. }
  12341. }
  12342. return lines;
  12343. };
  12344. TextBlock.prototype._parseLine = function (line, context) {
  12345. if (line === void 0) { line = ''; }
  12346. return { text: line, width: context.measureText(line).width };
  12347. };
  12348. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12349. if (line === void 0) { line = ''; }
  12350. var lineWidth = context.measureText(line).width;
  12351. if (lineWidth > width) {
  12352. line += '…';
  12353. }
  12354. while (line.length > 2 && lineWidth > width) {
  12355. line = line.slice(0, -2) + '…';
  12356. lineWidth = context.measureText(line).width;
  12357. }
  12358. return { text: line, width: lineWidth };
  12359. };
  12360. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12361. if (line === void 0) { line = ''; }
  12362. var lines = [];
  12363. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(' ');
  12364. var lineWidth = 0;
  12365. for (var n = 0; n < words.length; n++) {
  12366. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12367. var metrics = context.measureText(testLine);
  12368. var testWidth = metrics.width;
  12369. if (testWidth > width && n > 0) {
  12370. lines.push({ text: line, width: lineWidth });
  12371. line = words[n];
  12372. lineWidth = context.measureText(line).width;
  12373. }
  12374. else {
  12375. lineWidth = testWidth;
  12376. line = testLine;
  12377. }
  12378. }
  12379. lines.push({ text: line, width: lineWidth });
  12380. return lines;
  12381. };
  12382. TextBlock.prototype._renderLines = function (context) {
  12383. var height = this._currentMeasure.height;
  12384. var rootY = 0;
  12385. switch (this._textVerticalAlignment) {
  12386. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12387. rootY = this._fontOffset.ascent;
  12388. break;
  12389. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12390. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12391. break;
  12392. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12393. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12394. break;
  12395. }
  12396. rootY += this._currentMeasure.top;
  12397. for (var i = 0; i < this._lines.length; i++) {
  12398. var line = this._lines[i];
  12399. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12400. if (this._lineSpacing.isPixel) {
  12401. rootY += this._lineSpacing.getValue(this._host);
  12402. }
  12403. else {
  12404. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12405. }
  12406. }
  12407. this._drawText(line.text, line.width, rootY, context);
  12408. rootY += this._fontOffset.height;
  12409. }
  12410. };
  12411. /**
  12412. * Given a width constraint applied on the text block, find the expected height
  12413. * @returns expected height
  12414. */
  12415. TextBlock.prototype.computeExpectedHeight = function () {
  12416. if (this.text && this.widthInPixels) {
  12417. var context_1 = document.createElement('canvas').getContext('2d');
  12418. if (context_1) {
  12419. this._applyStates(context_1);
  12420. if (!this._fontOffset) {
  12421. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12422. }
  12423. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12424. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12425. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12426. var lineSpacing = 0;
  12427. if (this._lineSpacing.isPixel) {
  12428. lineSpacing = this._lineSpacing.getValue(this._host);
  12429. }
  12430. else {
  12431. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12432. }
  12433. newHeight += (lines.length - 1) * lineSpacing;
  12434. }
  12435. return newHeight;
  12436. }
  12437. }
  12438. return 0;
  12439. };
  12440. TextBlock.prototype.dispose = function () {
  12441. _super.prototype.dispose.call(this);
  12442. this.onTextChangedObservable.clear();
  12443. };
  12444. return TextBlock;
  12445. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12446. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12447. /***/ }),
  12448. /***/ "./2D/controls/virtualKeyboard.ts":
  12449. /*!****************************************!*\
  12450. !*** ./2D/controls/virtualKeyboard.ts ***!
  12451. \****************************************/
  12452. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12454. "use strict";
  12455. __webpack_require__.r(__webpack_exports__);
  12456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12461. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12462. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12463. /**
  12464. * Class used to store key control properties
  12465. */
  12466. var KeyPropertySet = /** @class */ (function () {
  12467. function KeyPropertySet() {
  12468. }
  12469. return KeyPropertySet;
  12470. }());
  12471. /**
  12472. * Class used to create virtual keyboard
  12473. */
  12474. var VirtualKeyboard = /** @class */ (function (_super) {
  12475. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12476. function VirtualKeyboard() {
  12477. var _this = _super !== null && _super.apply(this, arguments) || this;
  12478. /** Observable raised when a key is pressed */
  12479. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12480. /** Gets or sets default key button width */
  12481. _this.defaultButtonWidth = "40px";
  12482. /** Gets or sets default key button height */
  12483. _this.defaultButtonHeight = "40px";
  12484. /** Gets or sets default key button left padding */
  12485. _this.defaultButtonPaddingLeft = "2px";
  12486. /** Gets or sets default key button right padding */
  12487. _this.defaultButtonPaddingRight = "2px";
  12488. /** Gets or sets default key button top padding */
  12489. _this.defaultButtonPaddingTop = "2px";
  12490. /** Gets or sets default key button bottom padding */
  12491. _this.defaultButtonPaddingBottom = "2px";
  12492. /** Gets or sets default key button foreground color */
  12493. _this.defaultButtonColor = "#DDD";
  12494. /** Gets or sets default key button background color */
  12495. _this.defaultButtonBackground = "#070707";
  12496. /** Gets or sets shift button foreground color */
  12497. _this.shiftButtonColor = "#7799FF";
  12498. /** Gets or sets shift button thickness*/
  12499. _this.selectedShiftThickness = 1;
  12500. /** Gets shift key state */
  12501. _this.shiftState = 0;
  12502. _this._currentlyConnectedInputText = null;
  12503. _this._connectedInputTexts = [];
  12504. _this._onKeyPressObserver = null;
  12505. return _this;
  12506. }
  12507. VirtualKeyboard.prototype._getTypeName = function () {
  12508. return "VirtualKeyboard";
  12509. };
  12510. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12511. var _this = this;
  12512. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12513. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12514. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12515. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12516. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12517. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12518. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12519. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12520. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12521. button.thickness = 0;
  12522. button.isFocusInvisible = true;
  12523. button.shadowColor = this.shadowColor;
  12524. button.shadowBlur = this.shadowBlur;
  12525. button.shadowOffsetX = this.shadowOffsetX;
  12526. button.shadowOffsetY = this.shadowOffsetY;
  12527. button.onPointerUpObservable.add(function () {
  12528. _this.onKeyPressObservable.notifyObservers(key);
  12529. });
  12530. return button;
  12531. };
  12532. /**
  12533. * Adds a new row of keys
  12534. * @param keys defines the list of keys to add
  12535. * @param propertySets defines the associated property sets
  12536. */
  12537. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12538. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12539. panel.isVertical = false;
  12540. panel.isFocusInvisible = true;
  12541. var maxKey = null;
  12542. for (var i = 0; i < keys.length; i++) {
  12543. var properties = null;
  12544. if (propertySets && propertySets.length === keys.length) {
  12545. properties = propertySets[i];
  12546. }
  12547. var key = this._createKey(keys[i], properties);
  12548. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12549. maxKey = key;
  12550. }
  12551. panel.addControl(key);
  12552. }
  12553. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12554. this.addControl(panel);
  12555. };
  12556. /**
  12557. * Set the shift key to a specific state
  12558. * @param shiftState defines the new shift state
  12559. */
  12560. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12561. if (!this.children) {
  12562. return;
  12563. }
  12564. for (var i = 0; i < this.children.length; i++) {
  12565. var row = this.children[i];
  12566. if (!row || !row.children) {
  12567. continue;
  12568. }
  12569. var rowContainer = row;
  12570. for (var j = 0; j < rowContainer.children.length; j++) {
  12571. var button = rowContainer.children[j];
  12572. if (!button || !button.children[0]) {
  12573. continue;
  12574. }
  12575. var button_tblock = button.children[0];
  12576. if (button_tblock.text === "\u21E7") {
  12577. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12578. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12579. }
  12580. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12581. }
  12582. }
  12583. };
  12584. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12585. /** Gets the input text control currently attached to the keyboard */
  12586. get: function () {
  12587. return this._currentlyConnectedInputText;
  12588. },
  12589. enumerable: false,
  12590. configurable: true
  12591. });
  12592. /**
  12593. * Connects the keyboard with an input text control
  12594. *
  12595. * @param input defines the target control
  12596. */
  12597. VirtualKeyboard.prototype.connect = function (input) {
  12598. var _this = this;
  12599. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12600. if (inputTextAlreadyConnected) {
  12601. return;
  12602. }
  12603. if (this._onKeyPressObserver === null) {
  12604. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12605. if (!_this._currentlyConnectedInputText) {
  12606. return;
  12607. }
  12608. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12609. switch (key) {
  12610. case "\u21E7":
  12611. _this.shiftState++;
  12612. if (_this.shiftState > 2) {
  12613. _this.shiftState = 0;
  12614. }
  12615. _this.applyShiftState(_this.shiftState);
  12616. return;
  12617. case "\u2190":
  12618. _this._currentlyConnectedInputText.processKey(8);
  12619. return;
  12620. case "\u21B5":
  12621. _this._currentlyConnectedInputText.processKey(13);
  12622. return;
  12623. }
  12624. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12625. if (_this.shiftState === 1) {
  12626. _this.shiftState = 0;
  12627. _this.applyShiftState(_this.shiftState);
  12628. }
  12629. });
  12630. }
  12631. this.isVisible = false;
  12632. this._currentlyConnectedInputText = input;
  12633. input._connectedVirtualKeyboard = this;
  12634. // Events hooking
  12635. var onFocusObserver = input.onFocusObservable.add(function () {
  12636. _this._currentlyConnectedInputText = input;
  12637. input._connectedVirtualKeyboard = _this;
  12638. _this.isVisible = true;
  12639. });
  12640. var onBlurObserver = input.onBlurObservable.add(function () {
  12641. input._connectedVirtualKeyboard = null;
  12642. _this._currentlyConnectedInputText = null;
  12643. _this.isVisible = false;
  12644. });
  12645. this._connectedInputTexts.push({
  12646. input: input,
  12647. onBlurObserver: onBlurObserver,
  12648. onFocusObserver: onFocusObserver
  12649. });
  12650. };
  12651. /**
  12652. * Disconnects the keyboard from connected InputText controls
  12653. *
  12654. * @param input optionally defines a target control, otherwise all are disconnected
  12655. */
  12656. VirtualKeyboard.prototype.disconnect = function (input) {
  12657. var _this = this;
  12658. if (input) {
  12659. // .find not available on IE
  12660. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12661. if (filtered.length === 1) {
  12662. this._removeConnectedInputObservables(filtered[0]);
  12663. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12664. if (this._currentlyConnectedInputText === input) {
  12665. this._currentlyConnectedInputText = null;
  12666. }
  12667. }
  12668. }
  12669. else {
  12670. this._connectedInputTexts.forEach(function (connectedInputText) {
  12671. _this._removeConnectedInputObservables(connectedInputText);
  12672. });
  12673. this._connectedInputTexts = [];
  12674. }
  12675. if (this._connectedInputTexts.length === 0) {
  12676. this._currentlyConnectedInputText = null;
  12677. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12678. this._onKeyPressObserver = null;
  12679. }
  12680. };
  12681. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12682. connectedInputText.input._connectedVirtualKeyboard = null;
  12683. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12684. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12685. };
  12686. /**
  12687. * Release all resources
  12688. */
  12689. VirtualKeyboard.prototype.dispose = function () {
  12690. _super.prototype.dispose.call(this);
  12691. this.disconnect();
  12692. };
  12693. // Statics
  12694. /**
  12695. * Creates a new keyboard using a default layout
  12696. *
  12697. * @param name defines control name
  12698. * @returns a new VirtualKeyboard
  12699. */
  12700. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12701. var returnValue = new VirtualKeyboard(name);
  12702. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12703. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12704. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12705. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12706. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12707. return returnValue;
  12708. };
  12709. return VirtualKeyboard;
  12710. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12711. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12712. /***/ }),
  12713. /***/ "./2D/index.ts":
  12714. /*!*********************!*\
  12715. !*** ./2D/index.ts ***!
  12716. \*********************/
  12717. /*! 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 */
  12718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12719. "use strict";
  12720. __webpack_require__.r(__webpack_exports__);
  12721. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12754. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12756. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12758. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12761. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12763. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12765. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12767. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12769. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12771. /***/ }),
  12772. /***/ "./2D/math2D.ts":
  12773. /*!**********************!*\
  12774. !*** ./2D/math2D.ts ***!
  12775. \**********************/
  12776. /*! exports provided: Vector2WithInfo, Matrix2D */
  12777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12778. "use strict";
  12779. __webpack_require__.r(__webpack_exports__);
  12780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12782. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12783. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  12784. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12785. /**
  12786. * Class used to transport Vector2 information for pointer events
  12787. */
  12788. var Vector2WithInfo = /** @class */ (function (_super) {
  12789. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12790. /**
  12791. * Creates a new Vector2WithInfo
  12792. * @param source defines the vector2 data to transport
  12793. * @param buttonIndex defines the current mouse button index
  12794. */
  12795. function Vector2WithInfo(source,
  12796. /** defines the current mouse button index */
  12797. buttonIndex) {
  12798. if (buttonIndex === void 0) { buttonIndex = 0; }
  12799. var _this = _super.call(this, source.x, source.y) || this;
  12800. _this.buttonIndex = buttonIndex;
  12801. return _this;
  12802. }
  12803. return Vector2WithInfo;
  12804. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12805. /** Class used to provide 2D matrix features */
  12806. var Matrix2D = /** @class */ (function () {
  12807. /**
  12808. * Creates a new matrix
  12809. * @param m00 defines value for (0, 0)
  12810. * @param m01 defines value for (0, 1)
  12811. * @param m10 defines value for (1, 0)
  12812. * @param m11 defines value for (1, 1)
  12813. * @param m20 defines value for (2, 0)
  12814. * @param m21 defines value for (2, 1)
  12815. */
  12816. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12817. /** Gets the internal array of 6 floats used to store matrix data */
  12818. this.m = new Float32Array(6);
  12819. this.fromValues(m00, m01, m10, m11, m20, m21);
  12820. }
  12821. /**
  12822. * Fills the matrix from direct values
  12823. * @param m00 defines value for (0, 0)
  12824. * @param m01 defines value for (0, 1)
  12825. * @param m10 defines value for (1, 0)
  12826. * @param m11 defines value for (1, 1)
  12827. * @param m20 defines value for (2, 0)
  12828. * @param m21 defines value for (2, 1)
  12829. * @returns the current modified matrix
  12830. */
  12831. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12832. this.m[0] = m00;
  12833. this.m[1] = m01;
  12834. this.m[2] = m10;
  12835. this.m[3] = m11;
  12836. this.m[4] = m20;
  12837. this.m[5] = m21;
  12838. return this;
  12839. };
  12840. /**
  12841. * Gets matrix determinant
  12842. * @returns the determinant
  12843. */
  12844. Matrix2D.prototype.determinant = function () {
  12845. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12846. };
  12847. /**
  12848. * Inverses the matrix and stores it in a target matrix
  12849. * @param result defines the target matrix
  12850. * @returns the current matrix
  12851. */
  12852. Matrix2D.prototype.invertToRef = function (result) {
  12853. var l0 = this.m[0];
  12854. var l1 = this.m[1];
  12855. var l2 = this.m[2];
  12856. var l3 = this.m[3];
  12857. var l4 = this.m[4];
  12858. var l5 = this.m[5];
  12859. var det = this.determinant();
  12860. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12861. result.m[0] = 0;
  12862. result.m[1] = 0;
  12863. result.m[2] = 0;
  12864. result.m[3] = 0;
  12865. result.m[4] = 0;
  12866. result.m[5] = 0;
  12867. return this;
  12868. }
  12869. var detDiv = 1 / det;
  12870. var det4 = l2 * l5 - l3 * l4;
  12871. var det5 = l1 * l4 - l0 * l5;
  12872. result.m[0] = l3 * detDiv;
  12873. result.m[1] = -l1 * detDiv;
  12874. result.m[2] = -l2 * detDiv;
  12875. result.m[3] = l0 * detDiv;
  12876. result.m[4] = det4 * detDiv;
  12877. result.m[5] = det5 * detDiv;
  12878. return this;
  12879. };
  12880. /**
  12881. * Multiplies the current matrix with another one
  12882. * @param other defines the second operand
  12883. * @param result defines the target matrix
  12884. * @returns the current matrix
  12885. */
  12886. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12887. var l0 = this.m[0];
  12888. var l1 = this.m[1];
  12889. var l2 = this.m[2];
  12890. var l3 = this.m[3];
  12891. var l4 = this.m[4];
  12892. var l5 = this.m[5];
  12893. var r0 = other.m[0];
  12894. var r1 = other.m[1];
  12895. var r2 = other.m[2];
  12896. var r3 = other.m[3];
  12897. var r4 = other.m[4];
  12898. var r5 = other.m[5];
  12899. result.m[0] = l0 * r0 + l1 * r2;
  12900. result.m[1] = l0 * r1 + l1 * r3;
  12901. result.m[2] = l2 * r0 + l3 * r2;
  12902. result.m[3] = l2 * r1 + l3 * r3;
  12903. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12904. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12905. return this;
  12906. };
  12907. /**
  12908. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12909. * @param x defines the x coordinate to transform
  12910. * @param y defines the x coordinate to transform
  12911. * @param result defines the target vector2
  12912. * @returns the current matrix
  12913. */
  12914. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12915. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12916. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12917. return this;
  12918. };
  12919. // Statics
  12920. /**
  12921. * Creates an identity matrix
  12922. * @returns a new matrix
  12923. */
  12924. Matrix2D.Identity = function () {
  12925. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12926. };
  12927. /**
  12928. * Creates a translation matrix and stores it in a target matrix
  12929. * @param x defines the x coordinate of the translation
  12930. * @param y defines the y coordinate of the translation
  12931. * @param result defines the target matrix
  12932. */
  12933. Matrix2D.TranslationToRef = function (x, y, result) {
  12934. result.fromValues(1, 0, 0, 1, x, y);
  12935. };
  12936. /**
  12937. * Creates a scaling matrix and stores it in a target matrix
  12938. * @param x defines the x coordinate of the scaling
  12939. * @param y defines the y coordinate of the scaling
  12940. * @param result defines the target matrix
  12941. */
  12942. Matrix2D.ScalingToRef = function (x, y, result) {
  12943. result.fromValues(x, 0, 0, y, 0, 0);
  12944. };
  12945. /**
  12946. * Creates a rotation matrix and stores it in a target matrix
  12947. * @param angle defines the rotation angle
  12948. * @param result defines the target matrix
  12949. */
  12950. Matrix2D.RotationToRef = function (angle, result) {
  12951. var s = Math.sin(angle);
  12952. var c = Math.cos(angle);
  12953. result.fromValues(c, s, -s, c, 0, 0);
  12954. };
  12955. /**
  12956. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12957. * @param tx defines the x coordinate of the translation
  12958. * @param ty defines the y coordinate of the translation
  12959. * @param angle defines the rotation angle
  12960. * @param scaleX defines the x coordinate of the scaling
  12961. * @param scaleY defines the y coordinate of the scaling
  12962. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12963. * @param result defines the target matrix
  12964. */
  12965. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12966. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12967. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12968. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12969. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12970. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12971. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12972. if (parentMatrix) {
  12973. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12974. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12975. }
  12976. else {
  12977. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12978. }
  12979. };
  12980. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12981. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12982. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12983. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12984. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12985. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12986. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12987. return Matrix2D;
  12988. }());
  12989. /***/ }),
  12990. /***/ "./2D/measure.ts":
  12991. /*!***********************!*\
  12992. !*** ./2D/measure.ts ***!
  12993. \***********************/
  12994. /*! exports provided: Measure */
  12995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12996. "use strict";
  12997. __webpack_require__.r(__webpack_exports__);
  12998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12999. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  13000. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13001. var tmpRect = [
  13002. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13003. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13004. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13005. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13006. ];
  13007. var tmpRect2 = [
  13008. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13009. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13010. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13011. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13012. ];
  13013. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13014. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13015. /**
  13016. * Class used to store 2D control sizes
  13017. */
  13018. var Measure = /** @class */ (function () {
  13019. /**
  13020. * Creates a new measure
  13021. * @param left defines left coordinate
  13022. * @param top defines top coordinate
  13023. * @param width defines width dimension
  13024. * @param height defines height dimension
  13025. */
  13026. function Measure(
  13027. /** defines left coordinate */
  13028. left,
  13029. /** defines top coordinate */
  13030. top,
  13031. /** defines width dimension */
  13032. width,
  13033. /** defines height dimension */
  13034. height) {
  13035. this.left = left;
  13036. this.top = top;
  13037. this.width = width;
  13038. this.height = height;
  13039. }
  13040. /**
  13041. * Copy from another measure
  13042. * @param other defines the other measure to copy from
  13043. */
  13044. Measure.prototype.copyFrom = function (other) {
  13045. this.left = other.left;
  13046. this.top = other.top;
  13047. this.width = other.width;
  13048. this.height = other.height;
  13049. };
  13050. /**
  13051. * Copy from a group of 4 floats
  13052. * @param left defines left coordinate
  13053. * @param top defines top coordinate
  13054. * @param width defines width dimension
  13055. * @param height defines height dimension
  13056. */
  13057. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13058. this.left = left;
  13059. this.top = top;
  13060. this.width = width;
  13061. this.height = height;
  13062. };
  13063. /**
  13064. * Computes the axis aligned bounding box measure for two given measures
  13065. * @param a Input measure
  13066. * @param b Input measure
  13067. * @param result the resulting bounding measure
  13068. */
  13069. Measure.CombineToRef = function (a, b, result) {
  13070. var left = Math.min(a.left, b.left);
  13071. var top = Math.min(a.top, b.top);
  13072. var right = Math.max(a.left + a.width, b.left + b.width);
  13073. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13074. result.left = left;
  13075. result.top = top;
  13076. result.width = right - left;
  13077. result.height = bottom - top;
  13078. };
  13079. /**
  13080. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13081. * @param transform the matrix to transform the measure before computing the AABB
  13082. * @param result the resulting AABB
  13083. */
  13084. Measure.prototype.transformToRef = function (transform, result) {
  13085. tmpRect[0].copyFromFloats(this.left, this.top);
  13086. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  13087. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  13088. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  13089. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13090. tmpV2.copyFromFloats(0, 0);
  13091. for (var i = 0; i < 4; i++) {
  13092. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13093. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13094. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13095. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13096. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13097. }
  13098. result.left = tmpV1.x;
  13099. result.top = tmpV1.y;
  13100. result.width = tmpV2.x - tmpV1.x;
  13101. result.height = tmpV2.y - tmpV1.y;
  13102. };
  13103. /**
  13104. * Check equality between this measure and another one
  13105. * @param other defines the other measures
  13106. * @returns true if both measures are equals
  13107. */
  13108. Measure.prototype.isEqualsTo = function (other) {
  13109. if (this.left !== other.left) {
  13110. return false;
  13111. }
  13112. if (this.top !== other.top) {
  13113. return false;
  13114. }
  13115. if (this.width !== other.width) {
  13116. return false;
  13117. }
  13118. if (this.height !== other.height) {
  13119. return false;
  13120. }
  13121. return true;
  13122. };
  13123. /**
  13124. * Creates an empty measure
  13125. * @returns a new measure
  13126. */
  13127. Measure.Empty = function () {
  13128. return new Measure(0, 0, 0, 0);
  13129. };
  13130. return Measure;
  13131. }());
  13132. /***/ }),
  13133. /***/ "./2D/multiLinePoint.ts":
  13134. /*!******************************!*\
  13135. !*** ./2D/multiLinePoint.ts ***!
  13136. \******************************/
  13137. /*! exports provided: MultiLinePoint */
  13138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13139. "use strict";
  13140. __webpack_require__.r(__webpack_exports__);
  13141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13142. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  13143. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13144. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13145. /**
  13146. * Class used to store a point for a MultiLine object.
  13147. * The point can be pure 2D coordinates, a mesh or a control
  13148. */
  13149. var MultiLinePoint = /** @class */ (function () {
  13150. /**
  13151. * Creates a new MultiLinePoint
  13152. * @param multiLine defines the source MultiLine object
  13153. */
  13154. function MultiLinePoint(multiLine) {
  13155. this._multiLine = multiLine;
  13156. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13157. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13158. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13159. }
  13160. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13161. /** Gets or sets x coordinate */
  13162. get: function () {
  13163. return this._x.toString(this._multiLine._host);
  13164. },
  13165. set: function (value) {
  13166. if (this._x.toString(this._multiLine._host) === value) {
  13167. return;
  13168. }
  13169. if (this._x.fromString(value)) {
  13170. this._multiLine._markAsDirty();
  13171. }
  13172. },
  13173. enumerable: false,
  13174. configurable: true
  13175. });
  13176. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13177. /** Gets or sets y coordinate */
  13178. get: function () {
  13179. return this._y.toString(this._multiLine._host);
  13180. },
  13181. set: function (value) {
  13182. if (this._y.toString(this._multiLine._host) === value) {
  13183. return;
  13184. }
  13185. if (this._y.fromString(value)) {
  13186. this._multiLine._markAsDirty();
  13187. }
  13188. },
  13189. enumerable: false,
  13190. configurable: true
  13191. });
  13192. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13193. /** Gets or sets the control associated with this point */
  13194. get: function () {
  13195. return this._control;
  13196. },
  13197. set: function (value) {
  13198. if (this._control === value) {
  13199. return;
  13200. }
  13201. if (this._control && this._controlObserver) {
  13202. this._control.onDirtyObservable.remove(this._controlObserver);
  13203. this._controlObserver = null;
  13204. }
  13205. this._control = value;
  13206. if (this._control) {
  13207. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13208. }
  13209. this._multiLine._markAsDirty();
  13210. },
  13211. enumerable: false,
  13212. configurable: true
  13213. });
  13214. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13215. /** Gets or sets the mesh associated with this point */
  13216. get: function () {
  13217. return this._mesh;
  13218. },
  13219. set: function (value) {
  13220. if (this._mesh === value) {
  13221. return;
  13222. }
  13223. if (this._mesh && this._meshObserver) {
  13224. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13225. }
  13226. this._mesh = value;
  13227. if (this._mesh) {
  13228. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13229. }
  13230. this._multiLine._markAsDirty();
  13231. },
  13232. enumerable: false,
  13233. configurable: true
  13234. });
  13235. /** Resets links */
  13236. MultiLinePoint.prototype.resetLinks = function () {
  13237. this.control = null;
  13238. this.mesh = null;
  13239. };
  13240. /**
  13241. * Gets a translation vector
  13242. * @returns the translation vector
  13243. */
  13244. MultiLinePoint.prototype.translate = function () {
  13245. this._point = this._translatePoint();
  13246. return this._point;
  13247. };
  13248. MultiLinePoint.prototype._translatePoint = function () {
  13249. if (this._mesh != null) {
  13250. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13251. }
  13252. else if (this._control != null) {
  13253. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13254. }
  13255. else {
  13256. var host = this._multiLine._host;
  13257. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13258. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13259. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13260. }
  13261. };
  13262. /** Release associated resources */
  13263. MultiLinePoint.prototype.dispose = function () {
  13264. this.resetLinks();
  13265. };
  13266. return MultiLinePoint;
  13267. }());
  13268. /***/ }),
  13269. /***/ "./2D/style.ts":
  13270. /*!*********************!*\
  13271. !*** ./2D/style.ts ***!
  13272. \*********************/
  13273. /*! exports provided: Style */
  13274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13275. "use strict";
  13276. __webpack_require__.r(__webpack_exports__);
  13277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13278. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13279. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13280. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13281. /**
  13282. * Define a style used by control to automatically setup properties based on a template.
  13283. * Only support font related properties so far
  13284. */
  13285. var Style = /** @class */ (function () {
  13286. /**
  13287. * Creates a new style object
  13288. * @param host defines the AdvancedDynamicTexture which hosts this style
  13289. */
  13290. function Style(host) {
  13291. this._fontFamily = "Arial";
  13292. this._fontStyle = "";
  13293. this._fontWeight = "";
  13294. /** @hidden */
  13295. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13296. /**
  13297. * Observable raised when the style values are changed
  13298. */
  13299. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13300. this._host = host;
  13301. }
  13302. Object.defineProperty(Style.prototype, "fontSize", {
  13303. /**
  13304. * Gets or sets the font size
  13305. */
  13306. get: function () {
  13307. return this._fontSize.toString(this._host);
  13308. },
  13309. set: function (value) {
  13310. if (this._fontSize.toString(this._host) === value) {
  13311. return;
  13312. }
  13313. if (this._fontSize.fromString(value)) {
  13314. this.onChangedObservable.notifyObservers(this);
  13315. }
  13316. },
  13317. enumerable: false,
  13318. configurable: true
  13319. });
  13320. Object.defineProperty(Style.prototype, "fontFamily", {
  13321. /**
  13322. * Gets or sets the font family
  13323. */
  13324. get: function () {
  13325. return this._fontFamily;
  13326. },
  13327. set: function (value) {
  13328. if (this._fontFamily === value) {
  13329. return;
  13330. }
  13331. this._fontFamily = value;
  13332. this.onChangedObservable.notifyObservers(this);
  13333. },
  13334. enumerable: false,
  13335. configurable: true
  13336. });
  13337. Object.defineProperty(Style.prototype, "fontStyle", {
  13338. /**
  13339. * Gets or sets the font style
  13340. */
  13341. get: function () {
  13342. return this._fontStyle;
  13343. },
  13344. set: function (value) {
  13345. if (this._fontStyle === value) {
  13346. return;
  13347. }
  13348. this._fontStyle = value;
  13349. this.onChangedObservable.notifyObservers(this);
  13350. },
  13351. enumerable: false,
  13352. configurable: true
  13353. });
  13354. Object.defineProperty(Style.prototype, "fontWeight", {
  13355. /** Gets or sets font weight */
  13356. get: function () {
  13357. return this._fontWeight;
  13358. },
  13359. set: function (value) {
  13360. if (this._fontWeight === value) {
  13361. return;
  13362. }
  13363. this._fontWeight = value;
  13364. this.onChangedObservable.notifyObservers(this);
  13365. },
  13366. enumerable: false,
  13367. configurable: true
  13368. });
  13369. /** Dispose all associated resources */
  13370. Style.prototype.dispose = function () {
  13371. this.onChangedObservable.clear();
  13372. };
  13373. return Style;
  13374. }());
  13375. /***/ }),
  13376. /***/ "./2D/valueAndUnit.ts":
  13377. /*!****************************!*\
  13378. !*** ./2D/valueAndUnit.ts ***!
  13379. \****************************/
  13380. /*! exports provided: ValueAndUnit */
  13381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13382. "use strict";
  13383. __webpack_require__.r(__webpack_exports__);
  13384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13385. /**
  13386. * Class used to specific a value and its associated unit
  13387. */
  13388. var ValueAndUnit = /** @class */ (function () {
  13389. /**
  13390. * Creates a new ValueAndUnit
  13391. * @param value defines the value to store
  13392. * @param unit defines the unit to store
  13393. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13394. */
  13395. function ValueAndUnit(value,
  13396. /** defines the unit to store */
  13397. unit,
  13398. /** defines a boolean indicating if the value can be negative */
  13399. negativeValueAllowed) {
  13400. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13401. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13402. this.unit = unit;
  13403. this.negativeValueAllowed = negativeValueAllowed;
  13404. this._value = 1;
  13405. /**
  13406. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13407. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13408. */
  13409. this.ignoreAdaptiveScaling = false;
  13410. this._value = value;
  13411. this._originalUnit = unit;
  13412. }
  13413. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13414. /** Gets a boolean indicating if the value is a percentage */
  13415. get: function () {
  13416. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13417. },
  13418. enumerable: false,
  13419. configurable: true
  13420. });
  13421. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13422. /** Gets a boolean indicating if the value is store as pixel */
  13423. get: function () {
  13424. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13425. },
  13426. enumerable: false,
  13427. configurable: true
  13428. });
  13429. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13430. /** Gets direct internal value */
  13431. get: function () {
  13432. return this._value;
  13433. },
  13434. enumerable: false,
  13435. configurable: true
  13436. });
  13437. /**
  13438. * Gets value as pixel
  13439. * @param host defines the root host
  13440. * @param refValue defines the reference value for percentages
  13441. * @returns the value as pixel
  13442. */
  13443. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13444. if (this.isPixel) {
  13445. return this.getValue(host);
  13446. }
  13447. return this.getValue(host) * refValue;
  13448. };
  13449. /**
  13450. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13451. * @param value defines the value to store
  13452. * @param unit defines the unit to store
  13453. * @returns the current ValueAndUnit
  13454. */
  13455. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13456. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13457. this._value = value;
  13458. this.unit = unit;
  13459. return this;
  13460. };
  13461. /**
  13462. * Gets the value accordingly to its unit
  13463. * @param host defines the root host
  13464. * @returns the value
  13465. */
  13466. ValueAndUnit.prototype.getValue = function (host) {
  13467. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13468. var width = 0;
  13469. var height = 0;
  13470. if (host.idealWidth) {
  13471. width = (this._value * host.getSize().width) / host.idealWidth;
  13472. }
  13473. if (host.idealHeight) {
  13474. height = (this._value * host.getSize().height) / host.idealHeight;
  13475. }
  13476. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13477. return window.innerWidth < window.innerHeight ? width : height;
  13478. }
  13479. if (host.idealWidth) { // horizontal
  13480. return width;
  13481. }
  13482. if (host.idealHeight) { // vertical
  13483. return height;
  13484. }
  13485. }
  13486. return this._value;
  13487. };
  13488. /**
  13489. * Gets a string representation of the value
  13490. * @param host defines the root host
  13491. * @param decimals defines an optional number of decimals to display
  13492. * @returns a string
  13493. */
  13494. ValueAndUnit.prototype.toString = function (host, decimals) {
  13495. switch (this.unit) {
  13496. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13497. var percentage = this.getValue(host) * 100;
  13498. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13499. case ValueAndUnit.UNITMODE_PIXEL:
  13500. var pixels = this.getValue(host);
  13501. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13502. }
  13503. return this.unit.toString();
  13504. };
  13505. /**
  13506. * Store a value parsed from a string
  13507. * @param source defines the source string
  13508. * @returns true if the value was successfully parsed
  13509. */
  13510. ValueAndUnit.prototype.fromString = function (source) {
  13511. var match = ValueAndUnit._Regex.exec(source.toString());
  13512. if (!match || match.length === 0) {
  13513. return false;
  13514. }
  13515. var sourceValue = parseFloat(match[1]);
  13516. var sourceUnit = this._originalUnit;
  13517. if (!this.negativeValueAllowed) {
  13518. if (sourceValue < 0) {
  13519. sourceValue = 0;
  13520. }
  13521. }
  13522. if (match.length === 4) {
  13523. switch (match[3]) {
  13524. case "px":
  13525. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13526. break;
  13527. case "%":
  13528. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13529. sourceValue /= 100.0;
  13530. break;
  13531. }
  13532. }
  13533. if (sourceValue === this._value && sourceUnit === this.unit) {
  13534. return false;
  13535. }
  13536. this._value = sourceValue;
  13537. this.unit = sourceUnit;
  13538. return true;
  13539. };
  13540. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13541. /** UNITMODE_PERCENTAGE */
  13542. get: function () {
  13543. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13544. },
  13545. enumerable: false,
  13546. configurable: true
  13547. });
  13548. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13549. /** UNITMODE_PIXEL */
  13550. get: function () {
  13551. return ValueAndUnit._UNITMODE_PIXEL;
  13552. },
  13553. enumerable: false,
  13554. configurable: true
  13555. });
  13556. // Static
  13557. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13558. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13559. ValueAndUnit._UNITMODE_PIXEL = 1;
  13560. return ValueAndUnit;
  13561. }());
  13562. /***/ }),
  13563. /***/ "./2D/xmlLoader.ts":
  13564. /*!*************************!*\
  13565. !*** ./2D/xmlLoader.ts ***!
  13566. \*************************/
  13567. /*! exports provided: XmlLoader */
  13568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13569. "use strict";
  13570. __webpack_require__.r(__webpack_exports__);
  13571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13572. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  13573. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13574. /**
  13575. * Class used to load GUI via XML.
  13576. */
  13577. var XmlLoader = /** @class */ (function () {
  13578. /**
  13579. * Create a new xml loader
  13580. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13581. */
  13582. function XmlLoader(parentClass) {
  13583. if (parentClass === void 0) { parentClass = null; }
  13584. this._nodes = {};
  13585. this._nodeTypes = {
  13586. element: 1,
  13587. attribute: 2,
  13588. text: 3
  13589. };
  13590. this._isLoaded = false;
  13591. this._objectAttributes = {
  13592. "textHorizontalAlignment": 1,
  13593. "textVerticalAlignment": 2,
  13594. "horizontalAlignment": 3,
  13595. "verticalAlignment": 4,
  13596. "stretch": 5,
  13597. };
  13598. if (parentClass) {
  13599. this._parentClass = parentClass;
  13600. }
  13601. }
  13602. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13603. var element = window;
  13604. if (this._parentClass) {
  13605. element = this._parentClass;
  13606. }
  13607. var value = attributeValue;
  13608. value = value.split(".");
  13609. for (var i = 0; i < value.length; i++) {
  13610. element = element[value[i]];
  13611. }
  13612. return element;
  13613. };
  13614. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13615. var attribute = attributeName.split(".");
  13616. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13617. return className[attribute[1]];
  13618. };
  13619. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13620. if (linkParent === void 0) { linkParent = true; }
  13621. try {
  13622. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13623. var guiNode = new className();
  13624. if (parent && linkParent) {
  13625. parent.addControl(guiNode);
  13626. }
  13627. for (var i = 0; i < node.attributes.length; i++) {
  13628. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13629. continue;
  13630. }
  13631. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13632. var element = this._getChainElement(node.attributes[i].value);
  13633. guiNode[node.attributes[i].name].add(element);
  13634. continue;
  13635. }
  13636. else if (node.attributes[i].name == "linkWithMesh") {
  13637. if (this._parentClass) {
  13638. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13639. }
  13640. else {
  13641. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13642. }
  13643. }
  13644. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13645. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13646. guiNode[node.attributes[i].name] = element;
  13647. }
  13648. else if (!this._objectAttributes[node.attributes[i].name]) {
  13649. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13650. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13651. }
  13652. else {
  13653. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13654. }
  13655. }
  13656. else {
  13657. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13658. }
  13659. }
  13660. if (!node.attributes.getNamedItem("id")) {
  13661. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13662. return guiNode;
  13663. }
  13664. var id = node.attributes.getNamedItem("id").value;
  13665. if (id.startsWith("{{") && id.endsWith("}}")) {
  13666. id = this._getChainElement(id.substring(2, id.length - 2));
  13667. }
  13668. if (!this._nodes[id]) {
  13669. this._nodes[id] = guiNode;
  13670. }
  13671. else {
  13672. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13673. }
  13674. return guiNode;
  13675. }
  13676. catch (e) {
  13677. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13678. }
  13679. };
  13680. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13681. var width;
  13682. var height;
  13683. var columns;
  13684. var rows = node.children;
  13685. var cells;
  13686. var isPixel = false;
  13687. var cellNode;
  13688. var rowNumber = -1;
  13689. var columnNumber = -1;
  13690. var totalColumnsNumber = 0;
  13691. for (var i = 0; i < rows.length; i++) {
  13692. if (rows[i].nodeType != this._nodeTypes.element) {
  13693. continue;
  13694. }
  13695. if (rows[i].nodeName != "Row") {
  13696. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13697. }
  13698. rowNumber += 1;
  13699. columns = rows[i].children;
  13700. if (!rows[i].attributes.getNamedItem("height")) {
  13701. throw "XmlLoader Exception : Height must be defined for grid rows";
  13702. }
  13703. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13704. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13705. guiNode.addRowDefinition(height, isPixel);
  13706. for (var j = 0; j < columns.length; j++) {
  13707. if (columns[j].nodeType != this._nodeTypes.element) {
  13708. continue;
  13709. }
  13710. if (columns[j].nodeName != "Column") {
  13711. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13712. }
  13713. columnNumber += 1;
  13714. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13715. 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.";
  13716. }
  13717. if (rowNumber == 0) {
  13718. if (!columns[j].attributes.getNamedItem("width")) {
  13719. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13720. }
  13721. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13722. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13723. guiNode.addColumnDefinition(width, isPixel);
  13724. }
  13725. cells = columns[j].children;
  13726. for (var k = 0; k < cells.length; k++) {
  13727. if (cells[k].nodeType != this._nodeTypes.element) {
  13728. continue;
  13729. }
  13730. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13731. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13732. if (cells[k].firstChild) {
  13733. this._parseXml(cells[k].firstChild, cellNode);
  13734. }
  13735. }
  13736. }
  13737. if (rowNumber == 0) {
  13738. totalColumnsNumber = columnNumber;
  13739. }
  13740. columnNumber = -1;
  13741. }
  13742. if (node.nextSibling) {
  13743. this._parseXml(node.nextSibling, parent);
  13744. }
  13745. };
  13746. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13747. if (node.firstChild) {
  13748. this._parseXml(node.firstChild, guiNode);
  13749. }
  13750. if (node.nextSibling) {
  13751. this._parseXml(node.nextSibling, parent);
  13752. }
  13753. };
  13754. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13755. if (this._parentClass) {
  13756. this._parentClass[variable] = source[iterator];
  13757. }
  13758. else {
  13759. window[variable] = source[iterator];
  13760. }
  13761. if (node.firstChild) {
  13762. this._parseXml(node.firstChild, guiNode, true);
  13763. }
  13764. };
  13765. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13766. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13767. if (!dataSource.includes(" in ")) {
  13768. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13769. }
  13770. else {
  13771. var isArray = true;
  13772. var splittedSource = dataSource.split(" in ");
  13773. if (splittedSource.length < 2) {
  13774. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13775. }
  13776. var source = splittedSource[1];
  13777. if (source.startsWith("{") && source.endsWith("}")) {
  13778. isArray = false;
  13779. }
  13780. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13781. source = source.substring(1, source.length - 1);
  13782. }
  13783. if (this._parentClass) {
  13784. source = this._parentClass[source];
  13785. }
  13786. else {
  13787. source = window[source];
  13788. }
  13789. if (isArray) {
  13790. for (var i = 0; i < source.length; i++) {
  13791. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13792. }
  13793. }
  13794. else {
  13795. for (var i in source) {
  13796. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13797. }
  13798. }
  13799. if (node.nextSibling) {
  13800. this._parseXml(node.nextSibling, parent);
  13801. }
  13802. }
  13803. };
  13804. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13805. if (generated === void 0) { generated = false; }
  13806. if (node.nodeType != this._nodeTypes.element) {
  13807. if (node.nextSibling) {
  13808. this._parseXml(node.nextSibling, parent, generated);
  13809. }
  13810. return;
  13811. }
  13812. if (generated) {
  13813. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13814. }
  13815. var guiNode = this._createGuiElement(node, parent);
  13816. if (node.nodeName == "Grid") {
  13817. this._parseGrid(node, guiNode, parent);
  13818. }
  13819. else if (!node.attributes.getNamedItem("dataSource")) {
  13820. this._parseElement(node, guiNode, parent);
  13821. }
  13822. else {
  13823. this._parseElementsFromSource(node, guiNode, parent);
  13824. }
  13825. };
  13826. /**
  13827. * Gets if the loading has finished.
  13828. * @returns whether the loading has finished or not
  13829. */
  13830. XmlLoader.prototype.isLoaded = function () {
  13831. return this._isLoaded;
  13832. };
  13833. /**
  13834. * Gets a loaded node / control by id.
  13835. * @param id the Controls id set in the xml
  13836. * @returns element of type Control
  13837. */
  13838. XmlLoader.prototype.getNodeById = function (id) {
  13839. return this._nodes[id];
  13840. };
  13841. /**
  13842. * Gets all loaded nodes / controls
  13843. * @returns Array of controls
  13844. */
  13845. XmlLoader.prototype.getNodes = function () {
  13846. return this._nodes;
  13847. };
  13848. /**
  13849. * Initiates the xml layout loading
  13850. * @param xmlFile defines the xml layout to load
  13851. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13852. * @param callback defines the callback called on layout load.
  13853. */
  13854. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13855. var xhttp = new XMLHttpRequest();
  13856. xhttp.onreadystatechange = function () {
  13857. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13858. if (!xhttp.responseXML) {
  13859. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13860. }
  13861. var xmlDoc = xhttp.responseXML.documentElement;
  13862. this._parseXml(xmlDoc.firstChild, rootNode);
  13863. this._isLoaded = true;
  13864. if (callback) {
  13865. callback();
  13866. }
  13867. }
  13868. }.bind(this);
  13869. xhttp.open("GET", xmlFile, true);
  13870. xhttp.send();
  13871. };
  13872. return XmlLoader;
  13873. }());
  13874. /***/ }),
  13875. /***/ "./3D/controls/abstractButton3D.ts":
  13876. /*!*****************************************!*\
  13877. !*** ./3D/controls/abstractButton3D.ts ***!
  13878. \*****************************************/
  13879. /*! exports provided: AbstractButton3D */
  13880. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13881. "use strict";
  13882. __webpack_require__.r(__webpack_exports__);
  13883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13884. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13885. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13886. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13887. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13888. /**
  13889. * Class used as a root to all buttons
  13890. */
  13891. var AbstractButton3D = /** @class */ (function (_super) {
  13892. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13893. /**
  13894. * Creates a new button
  13895. * @param name defines the control name
  13896. */
  13897. function AbstractButton3D(name) {
  13898. return _super.call(this, name) || this;
  13899. }
  13900. AbstractButton3D.prototype._getTypeName = function () {
  13901. return "AbstractButton3D";
  13902. };
  13903. // Mesh association
  13904. AbstractButton3D.prototype._createNode = function (scene) {
  13905. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13906. };
  13907. return AbstractButton3D;
  13908. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13909. /***/ }),
  13910. /***/ "./3D/controls/button3D.ts":
  13911. /*!*********************************!*\
  13912. !*** ./3D/controls/button3D.ts ***!
  13913. \*********************************/
  13914. /*! exports provided: Button3D */
  13915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13916. "use strict";
  13917. __webpack_require__.r(__webpack_exports__);
  13918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13919. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13920. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  13921. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13922. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13923. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13924. /**
  13925. * Class used to create a button in 3D
  13926. */
  13927. var Button3D = /** @class */ (function (_super) {
  13928. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13929. /**
  13930. * Creates a new button
  13931. * @param name defines the control name
  13932. */
  13933. function Button3D(name) {
  13934. var _this = _super.call(this, name) || this;
  13935. _this._contentResolution = 512;
  13936. _this._contentScaleRatio = 2;
  13937. // Default animations
  13938. _this.pointerEnterAnimation = function () {
  13939. if (!_this.mesh) {
  13940. return;
  13941. }
  13942. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13943. };
  13944. _this.pointerOutAnimation = function () {
  13945. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13946. };
  13947. _this.pointerDownAnimation = function () {
  13948. if (!_this.mesh) {
  13949. return;
  13950. }
  13951. _this.mesh.scaling.scaleInPlace(0.95);
  13952. };
  13953. _this.pointerUpAnimation = function () {
  13954. if (!_this.mesh) {
  13955. return;
  13956. }
  13957. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13958. };
  13959. return _this;
  13960. }
  13961. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13962. /**
  13963. * Gets or sets the texture resolution used to render content (512 by default)
  13964. */
  13965. get: function () {
  13966. return this._contentResolution;
  13967. },
  13968. set: function (value) {
  13969. if (this._contentResolution === value) {
  13970. return;
  13971. }
  13972. this._contentResolution = value;
  13973. this._resetContent();
  13974. },
  13975. enumerable: false,
  13976. configurable: true
  13977. });
  13978. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13979. /**
  13980. * Gets or sets the texture scale ratio used to render content (2 by default)
  13981. */
  13982. get: function () {
  13983. return this._contentScaleRatio;
  13984. },
  13985. set: function (value) {
  13986. if (this._contentScaleRatio === value) {
  13987. return;
  13988. }
  13989. this._contentScaleRatio = value;
  13990. this._resetContent();
  13991. },
  13992. enumerable: false,
  13993. configurable: true
  13994. });
  13995. Button3D.prototype._disposeFacadeTexture = function () {
  13996. if (this._facadeTexture) {
  13997. this._facadeTexture.dispose();
  13998. this._facadeTexture = null;
  13999. }
  14000. };
  14001. Button3D.prototype._resetContent = function () {
  14002. this._disposeFacadeTexture();
  14003. this.content = this._content;
  14004. };
  14005. Object.defineProperty(Button3D.prototype, "content", {
  14006. /**
  14007. * Gets or sets the GUI 2D content used to display the button's facade
  14008. */
  14009. get: function () {
  14010. return this._content;
  14011. },
  14012. set: function (value) {
  14013. this._content = value;
  14014. if (!this._host || !this._host.utilityLayer) {
  14015. return;
  14016. }
  14017. if (!this._facadeTexture) {
  14018. 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);
  14019. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  14020. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  14021. this._facadeTexture.premulAlpha = true;
  14022. }
  14023. else {
  14024. this._facadeTexture.rootContainer.clearControls();
  14025. }
  14026. this._facadeTexture.addControl(value);
  14027. this._applyFacade(this._facadeTexture);
  14028. },
  14029. enumerable: false,
  14030. configurable: true
  14031. });
  14032. /**
  14033. * Apply the facade texture (created from the content property).
  14034. * This function can be overloaded by child classes
  14035. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14036. */
  14037. Button3D.prototype._applyFacade = function (facadeTexture) {
  14038. this._currentMaterial.emissiveTexture = facadeTexture;
  14039. };
  14040. Button3D.prototype._getTypeName = function () {
  14041. return "Button3D";
  14042. };
  14043. // Mesh association
  14044. Button3D.prototype._createNode = function (scene) {
  14045. var faceUV = new Array(6);
  14046. for (var i = 0; i < 6; i++) {
  14047. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14048. }
  14049. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14050. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14051. width: 1.0,
  14052. height: 1.0,
  14053. depth: 0.08,
  14054. faceUV: faceUV
  14055. }, scene);
  14056. return mesh;
  14057. };
  14058. Button3D.prototype._affectMaterial = function (mesh) {
  14059. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14060. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14061. mesh.material = material;
  14062. this._currentMaterial = material;
  14063. this._resetContent();
  14064. };
  14065. /**
  14066. * Releases all associated resources
  14067. */
  14068. Button3D.prototype.dispose = function () {
  14069. _super.prototype.dispose.call(this);
  14070. this._disposeFacadeTexture();
  14071. if (this._currentMaterial) {
  14072. this._currentMaterial.dispose();
  14073. }
  14074. };
  14075. return Button3D;
  14076. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14077. /***/ }),
  14078. /***/ "./3D/controls/container3D.ts":
  14079. /*!************************************!*\
  14080. !*** ./3D/controls/container3D.ts ***!
  14081. \************************************/
  14082. /*! exports provided: Container3D */
  14083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14084. "use strict";
  14085. __webpack_require__.r(__webpack_exports__);
  14086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14087. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14088. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  14089. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14090. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14091. /**
  14092. * Class used to create containers for controls
  14093. */
  14094. var Container3D = /** @class */ (function (_super) {
  14095. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14096. /**
  14097. * Creates a new container
  14098. * @param name defines the container name
  14099. */
  14100. function Container3D(name) {
  14101. var _this = _super.call(this, name) || this;
  14102. _this._blockLayout = false;
  14103. /**
  14104. * Gets the list of child controls
  14105. */
  14106. _this._children = new Array();
  14107. return _this;
  14108. }
  14109. Object.defineProperty(Container3D.prototype, "children", {
  14110. /**
  14111. * Gets the list of child controls
  14112. */
  14113. get: function () {
  14114. return this._children;
  14115. },
  14116. enumerable: false,
  14117. configurable: true
  14118. });
  14119. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14120. /**
  14121. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14122. * This is helpful to optimize layout operation when adding multiple children in a row
  14123. */
  14124. get: function () {
  14125. return this._blockLayout;
  14126. },
  14127. set: function (value) {
  14128. if (this._blockLayout === value) {
  14129. return;
  14130. }
  14131. this._blockLayout = value;
  14132. if (!this._blockLayout) {
  14133. this._arrangeChildren();
  14134. }
  14135. },
  14136. enumerable: false,
  14137. configurable: true
  14138. });
  14139. /**
  14140. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14141. * @returns the current container
  14142. */
  14143. Container3D.prototype.updateLayout = function () {
  14144. this._arrangeChildren();
  14145. return this;
  14146. };
  14147. /**
  14148. * Gets a boolean indicating if the given control is in the children of this control
  14149. * @param control defines the control to check
  14150. * @returns true if the control is in the child list
  14151. */
  14152. Container3D.prototype.containsControl = function (control) {
  14153. return this._children.indexOf(control) !== -1;
  14154. };
  14155. /**
  14156. * Adds a control to the children of this control
  14157. * @param control defines the control to add
  14158. * @returns the current container
  14159. */
  14160. Container3D.prototype.addControl = function (control) {
  14161. var index = this._children.indexOf(control);
  14162. if (index !== -1) {
  14163. return this;
  14164. }
  14165. control.parent = this;
  14166. control._host = this._host;
  14167. this._children.push(control);
  14168. if (this._host.utilityLayer) {
  14169. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14170. if (control.node) {
  14171. control.node.parent = this.node;
  14172. }
  14173. if (!this.blockLayout) {
  14174. this._arrangeChildren();
  14175. }
  14176. }
  14177. return this;
  14178. };
  14179. /**
  14180. * This function will be called everytime a new control is added
  14181. */
  14182. Container3D.prototype._arrangeChildren = function () {
  14183. };
  14184. Container3D.prototype._createNode = function (scene) {
  14185. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14186. };
  14187. /**
  14188. * Removes a control from the children of this control
  14189. * @param control defines the control to remove
  14190. * @returns the current container
  14191. */
  14192. Container3D.prototype.removeControl = function (control) {
  14193. var index = this._children.indexOf(control);
  14194. if (index !== -1) {
  14195. this._children.splice(index, 1);
  14196. control.parent = null;
  14197. control._disposeNode();
  14198. }
  14199. return this;
  14200. };
  14201. Container3D.prototype._getTypeName = function () {
  14202. return "Container3D";
  14203. };
  14204. /**
  14205. * Releases all associated resources
  14206. */
  14207. Container3D.prototype.dispose = function () {
  14208. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14209. var control = _a[_i];
  14210. control.dispose();
  14211. }
  14212. this._children = [];
  14213. _super.prototype.dispose.call(this);
  14214. };
  14215. /** Control rotation will remain unchanged */
  14216. Container3D.UNSET_ORIENTATION = 0;
  14217. /** Control will rotate to make it look at sphere central axis */
  14218. Container3D.FACEORIGIN_ORIENTATION = 1;
  14219. /** Control will rotate to make it look back at sphere central axis */
  14220. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14221. /** Control will rotate to look at z axis (0, 0, 1) */
  14222. Container3D.FACEFORWARD_ORIENTATION = 3;
  14223. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14224. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14225. return Container3D;
  14226. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14227. /***/ }),
  14228. /***/ "./3D/controls/control3D.ts":
  14229. /*!**********************************!*\
  14230. !*** ./3D/controls/control3D.ts ***!
  14231. \**********************************/
  14232. /*! exports provided: Control3D */
  14233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14234. "use strict";
  14235. __webpack_require__.r(__webpack_exports__);
  14236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14237. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14238. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14239. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14240. /**
  14241. * Class used as base class for controls
  14242. */
  14243. var Control3D = /** @class */ (function () {
  14244. /**
  14245. * Creates a new control
  14246. * @param name defines the control name
  14247. */
  14248. function Control3D(
  14249. /** Defines the control name */
  14250. name) {
  14251. this.name = name;
  14252. this._downCount = 0;
  14253. this._enterCount = -1;
  14254. this._downPointerIds = {};
  14255. this._isVisible = true;
  14256. /**
  14257. * An event triggered when the pointer move over the control
  14258. */
  14259. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14260. /**
  14261. * An event triggered when the pointer move out of the control
  14262. */
  14263. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14264. /**
  14265. * An event triggered when the pointer taps the control
  14266. */
  14267. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14268. /**
  14269. * An event triggered when pointer is up
  14270. */
  14271. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14272. /**
  14273. * An event triggered when a control is clicked on (with a mouse)
  14274. */
  14275. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14276. /**
  14277. * An event triggered when pointer enters the control
  14278. */
  14279. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14280. // Behaviors
  14281. this._behaviors = new Array();
  14282. }
  14283. Object.defineProperty(Control3D.prototype, "position", {
  14284. /** Gets or sets the control position in world space */
  14285. get: function () {
  14286. if (!this._node) {
  14287. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14288. }
  14289. return this._node.position;
  14290. },
  14291. set: function (value) {
  14292. if (!this._node) {
  14293. return;
  14294. }
  14295. this._node.position = value;
  14296. },
  14297. enumerable: false,
  14298. configurable: true
  14299. });
  14300. Object.defineProperty(Control3D.prototype, "scaling", {
  14301. /** Gets or sets the control scaling in world space */
  14302. get: function () {
  14303. if (!this._node) {
  14304. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14305. }
  14306. return this._node.scaling;
  14307. },
  14308. set: function (value) {
  14309. if (!this._node) {
  14310. return;
  14311. }
  14312. this._node.scaling = value;
  14313. },
  14314. enumerable: false,
  14315. configurable: true
  14316. });
  14317. Object.defineProperty(Control3D.prototype, "behaviors", {
  14318. /**
  14319. * Gets the list of attached behaviors
  14320. * @see https://doc.babylonjs.com/features/behaviour
  14321. */
  14322. get: function () {
  14323. return this._behaviors;
  14324. },
  14325. enumerable: false,
  14326. configurable: true
  14327. });
  14328. /**
  14329. * Attach a behavior to the control
  14330. * @see https://doc.babylonjs.com/features/behaviour
  14331. * @param behavior defines the behavior to attach
  14332. * @returns the current control
  14333. */
  14334. Control3D.prototype.addBehavior = function (behavior) {
  14335. var _this = this;
  14336. var index = this._behaviors.indexOf(behavior);
  14337. if (index !== -1) {
  14338. return this;
  14339. }
  14340. behavior.init();
  14341. var scene = this._host.scene;
  14342. if (scene.isLoading) {
  14343. // We defer the attach when the scene will be loaded
  14344. scene.onDataLoadedObservable.addOnce(function () {
  14345. behavior.attach(_this);
  14346. });
  14347. }
  14348. else {
  14349. behavior.attach(this);
  14350. }
  14351. this._behaviors.push(behavior);
  14352. return this;
  14353. };
  14354. /**
  14355. * Remove an attached behavior
  14356. * @see https://doc.babylonjs.com/features/behaviour
  14357. * @param behavior defines the behavior to attach
  14358. * @returns the current control
  14359. */
  14360. Control3D.prototype.removeBehavior = function (behavior) {
  14361. var index = this._behaviors.indexOf(behavior);
  14362. if (index === -1) {
  14363. return this;
  14364. }
  14365. this._behaviors[index].detach();
  14366. this._behaviors.splice(index, 1);
  14367. return this;
  14368. };
  14369. /**
  14370. * Gets an attached behavior by name
  14371. * @param name defines the name of the behavior to look for
  14372. * @see https://doc.babylonjs.com/features/behaviour
  14373. * @returns null if behavior was not found else the requested behavior
  14374. */
  14375. Control3D.prototype.getBehaviorByName = function (name) {
  14376. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14377. var behavior = _a[_i];
  14378. if (behavior.name === name) {
  14379. return behavior;
  14380. }
  14381. }
  14382. return null;
  14383. };
  14384. Object.defineProperty(Control3D.prototype, "isVisible", {
  14385. /** Gets or sets a boolean indicating if the control is visible */
  14386. get: function () {
  14387. return this._isVisible;
  14388. },
  14389. set: function (value) {
  14390. if (this._isVisible === value) {
  14391. return;
  14392. }
  14393. this._isVisible = value;
  14394. var mesh = this.mesh;
  14395. if (mesh) {
  14396. mesh.setEnabled(value);
  14397. }
  14398. },
  14399. enumerable: false,
  14400. configurable: true
  14401. });
  14402. Object.defineProperty(Control3D.prototype, "typeName", {
  14403. /**
  14404. * Gets a string representing the class name
  14405. */
  14406. get: function () {
  14407. return this._getTypeName();
  14408. },
  14409. enumerable: false,
  14410. configurable: true
  14411. });
  14412. /**
  14413. * Get the current class name of the control.
  14414. * @returns current class name
  14415. */
  14416. Control3D.prototype.getClassName = function () {
  14417. return this._getTypeName();
  14418. };
  14419. Control3D.prototype._getTypeName = function () {
  14420. return "Control3D";
  14421. };
  14422. Object.defineProperty(Control3D.prototype, "node", {
  14423. /**
  14424. * Gets the transform node used by this control
  14425. */
  14426. get: function () {
  14427. return this._node;
  14428. },
  14429. enumerable: false,
  14430. configurable: true
  14431. });
  14432. Object.defineProperty(Control3D.prototype, "mesh", {
  14433. /**
  14434. * Gets the mesh used to render this control
  14435. */
  14436. get: function () {
  14437. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14438. return this._node;
  14439. }
  14440. return null;
  14441. },
  14442. enumerable: false,
  14443. configurable: true
  14444. });
  14445. /**
  14446. * Link the control as child of the given node
  14447. * @param node defines the node to link to. Use null to unlink the control
  14448. * @returns the current control
  14449. */
  14450. Control3D.prototype.linkToTransformNode = function (node) {
  14451. if (this._node) {
  14452. this._node.parent = node;
  14453. }
  14454. return this;
  14455. };
  14456. /** @hidden **/
  14457. Control3D.prototype._prepareNode = function (scene) {
  14458. if (!this._node) {
  14459. this._node = this._createNode(scene);
  14460. if (!this.node) {
  14461. return;
  14462. }
  14463. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14464. this._node.position = this.position;
  14465. this._node.scaling = this.scaling;
  14466. var mesh = this.mesh;
  14467. if (mesh) {
  14468. mesh.isPickable = true;
  14469. this._affectMaterial(mesh);
  14470. }
  14471. }
  14472. };
  14473. /**
  14474. * Node creation.
  14475. * Can be overriden by children
  14476. * @param scene defines the scene where the node must be attached
  14477. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14478. */
  14479. Control3D.prototype._createNode = function (scene) {
  14480. // Do nothing by default
  14481. return null;
  14482. };
  14483. /**
  14484. * Affect a material to the given mesh
  14485. * @param mesh defines the mesh which will represent the control
  14486. */
  14487. Control3D.prototype._affectMaterial = function (mesh) {
  14488. mesh.material = null;
  14489. };
  14490. // Pointers
  14491. /** @hidden */
  14492. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14493. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14494. };
  14495. /** @hidden */
  14496. Control3D.prototype._onPointerEnter = function (target) {
  14497. if (this._enterCount > 0) {
  14498. return false;
  14499. }
  14500. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14501. this._enterCount = 0;
  14502. }
  14503. this._enterCount++;
  14504. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14505. if (this.pointerEnterAnimation) {
  14506. this.pointerEnterAnimation();
  14507. }
  14508. return true;
  14509. };
  14510. /** @hidden */
  14511. Control3D.prototype._onPointerOut = function (target) {
  14512. this._enterCount = 0;
  14513. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14514. if (this.pointerOutAnimation) {
  14515. this.pointerOutAnimation();
  14516. }
  14517. };
  14518. /** @hidden */
  14519. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14520. if (this._downCount !== 0) {
  14521. this._downCount++;
  14522. return false;
  14523. }
  14524. this._downCount++;
  14525. this._downPointerIds[pointerId] = true;
  14526. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14527. if (this.pointerDownAnimation) {
  14528. this.pointerDownAnimation();
  14529. }
  14530. return true;
  14531. };
  14532. /** @hidden */
  14533. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14534. this._downCount--;
  14535. delete this._downPointerIds[pointerId];
  14536. if (this._downCount < 0) {
  14537. // Handle if forcePointerUp was called prior to this
  14538. this._downCount = 0;
  14539. return;
  14540. }
  14541. if (this._downCount == 0) {
  14542. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14543. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14544. }
  14545. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14546. if (this.pointerUpAnimation) {
  14547. this.pointerUpAnimation();
  14548. }
  14549. }
  14550. };
  14551. /** @hidden */
  14552. Control3D.prototype.forcePointerUp = function (pointerId) {
  14553. if (pointerId === void 0) { pointerId = null; }
  14554. if (pointerId !== null) {
  14555. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14556. }
  14557. else {
  14558. for (var key in this._downPointerIds) {
  14559. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14560. }
  14561. if (this._downCount > 0) {
  14562. this._downCount = 1;
  14563. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14564. }
  14565. }
  14566. };
  14567. /** @hidden */
  14568. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14569. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14570. this._onPointerMove(this, pickedPoint);
  14571. var previousControlOver = this._host._lastControlOver[pointerId];
  14572. if (previousControlOver && previousControlOver !== this) {
  14573. previousControlOver._onPointerOut(this);
  14574. }
  14575. if (previousControlOver !== this) {
  14576. this._onPointerEnter(this);
  14577. }
  14578. this._host._lastControlOver[pointerId] = this;
  14579. return true;
  14580. }
  14581. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14582. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14583. this._host._lastControlDown[pointerId] = this;
  14584. this._host._lastPickedControl = this;
  14585. return true;
  14586. }
  14587. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  14588. if (this._host._lastControlDown[pointerId]) {
  14589. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14590. }
  14591. delete this._host._lastControlDown[pointerId];
  14592. return true;
  14593. }
  14594. return false;
  14595. };
  14596. /** @hidden */
  14597. Control3D.prototype._disposeNode = function () {
  14598. if (this._node) {
  14599. this._node.dispose();
  14600. this._node = null;
  14601. }
  14602. };
  14603. /**
  14604. * Releases all associated resources
  14605. */
  14606. Control3D.prototype.dispose = function () {
  14607. this.onPointerDownObservable.clear();
  14608. this.onPointerEnterObservable.clear();
  14609. this.onPointerMoveObservable.clear();
  14610. this.onPointerOutObservable.clear();
  14611. this.onPointerUpObservable.clear();
  14612. this.onPointerClickObservable.clear();
  14613. this._disposeNode();
  14614. // Behaviors
  14615. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14616. var behavior = _a[_i];
  14617. behavior.detach();
  14618. }
  14619. };
  14620. return Control3D;
  14621. }());
  14622. /***/ }),
  14623. /***/ "./3D/controls/cylinderPanel.ts":
  14624. /*!**************************************!*\
  14625. !*** ./3D/controls/cylinderPanel.ts ***!
  14626. \**************************************/
  14627. /*! exports provided: CylinderPanel */
  14628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14629. "use strict";
  14630. __webpack_require__.r(__webpack_exports__);
  14631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14632. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14633. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14634. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14635. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14636. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14637. /**
  14638. * Class used to create a container panel deployed on the surface of a cylinder
  14639. */
  14640. var CylinderPanel = /** @class */ (function (_super) {
  14641. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14642. function CylinderPanel() {
  14643. var _this = _super !== null && _super.apply(this, arguments) || this;
  14644. _this._radius = 5.0;
  14645. return _this;
  14646. }
  14647. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14648. /**
  14649. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14650. */
  14651. get: function () {
  14652. return this._radius;
  14653. },
  14654. set: function (value) {
  14655. var _this = this;
  14656. if (this._radius === value) {
  14657. return;
  14658. }
  14659. this._radius = value;
  14660. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14661. _this._arrangeChildren();
  14662. });
  14663. },
  14664. enumerable: false,
  14665. configurable: true
  14666. });
  14667. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14668. var mesh = control.mesh;
  14669. if (!mesh) {
  14670. return;
  14671. }
  14672. var newPos = this._cylindricalMapping(nodePosition);
  14673. control.position = newPos;
  14674. switch (this.orientation) {
  14675. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14676. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14677. break;
  14678. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14679. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14680. break;
  14681. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14682. break;
  14683. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14684. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14685. break;
  14686. }
  14687. };
  14688. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14689. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14690. var yAngle = (source.x / this._radius);
  14691. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14692. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14693. };
  14694. return CylinderPanel;
  14695. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14696. /***/ }),
  14697. /***/ "./3D/controls/holographicButton.ts":
  14698. /*!******************************************!*\
  14699. !*** ./3D/controls/holographicButton.ts ***!
  14700. \******************************************/
  14701. /*! exports provided: HolographicButton */
  14702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14703. "use strict";
  14704. __webpack_require__.r(__webpack_exports__);
  14705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14707. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14708. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/perfCounter");
  14709. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14710. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14711. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14712. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14713. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14714. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14715. /**
  14716. * Class used to create a holographic button in 3D
  14717. */
  14718. var HolographicButton = /** @class */ (function (_super) {
  14719. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14720. /**
  14721. * Creates a new button
  14722. * @param name defines the control name
  14723. */
  14724. function HolographicButton(name, shareMaterials) {
  14725. if (shareMaterials === void 0) { shareMaterials = true; }
  14726. var _this = _super.call(this, name) || this;
  14727. _this._shareMaterials = true;
  14728. _this._shareMaterials = shareMaterials;
  14729. // Default animations
  14730. _this.pointerEnterAnimation = function () {
  14731. if (!_this.mesh) {
  14732. return;
  14733. }
  14734. _this._frontPlate.setEnabled(true);
  14735. };
  14736. _this.pointerOutAnimation = function () {
  14737. if (!_this.mesh) {
  14738. return;
  14739. }
  14740. _this._frontPlate.setEnabled(false);
  14741. };
  14742. return _this;
  14743. }
  14744. HolographicButton.prototype._disposeTooltip = function () {
  14745. this._tooltipFade = null;
  14746. if (this._tooltipTextBlock) {
  14747. this._tooltipTextBlock.dispose();
  14748. }
  14749. if (this._tooltipTexture) {
  14750. this._tooltipTexture.dispose();
  14751. }
  14752. if (this._tooltipMesh) {
  14753. this._tooltipMesh.dispose();
  14754. }
  14755. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14756. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14757. };
  14758. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14759. get: function () {
  14760. return this._backPlate.renderingGroupId;
  14761. },
  14762. /**
  14763. * Rendering ground id of all the mesh in the button
  14764. */
  14765. set: function (id) {
  14766. this._backPlate.renderingGroupId = id;
  14767. this._textPlate.renderingGroupId = id;
  14768. this._frontPlate.renderingGroupId = id;
  14769. if (this._tooltipMesh) {
  14770. this._tooltipMesh.renderingGroupId = id;
  14771. }
  14772. },
  14773. enumerable: false,
  14774. configurable: true
  14775. });
  14776. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14777. get: function () {
  14778. if (this._tooltipTextBlock) {
  14779. return this._tooltipTextBlock.text;
  14780. }
  14781. return null;
  14782. },
  14783. /**
  14784. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14785. */
  14786. set: function (text) {
  14787. var _this = this;
  14788. if (!text) {
  14789. this._disposeTooltip();
  14790. return;
  14791. }
  14792. if (!this._tooltipFade) {
  14793. // Create tooltip with mesh and text
  14794. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14795. 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);
  14796. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14797. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14798. tooltipBackground.material = mat;
  14799. tooltipBackground.isPickable = false;
  14800. this._tooltipMesh.addChild(tooltipBackground);
  14801. tooltipBackground.position.z = 0.05;
  14802. this._tooltipMesh.scaling.y = 1 / 3;
  14803. this._tooltipMesh.position.y = 0.7;
  14804. this._tooltipMesh.position.z = -0.15;
  14805. this._tooltipMesh.isPickable = false;
  14806. this._tooltipMesh.parent = this._backPlate;
  14807. // Create text texture for the tooltip
  14808. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14809. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14810. this._tooltipTextBlock.scaleY = 3;
  14811. this._tooltipTextBlock.color = "white";
  14812. this._tooltipTextBlock.fontSize = 130;
  14813. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14814. // Add hover action to tooltip
  14815. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14816. this._tooltipFade.delay = 500;
  14817. this._tooltipMesh.addBehavior(this._tooltipFade);
  14818. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14819. if (_this._tooltipFade) {
  14820. _this._tooltipFade.fadeIn(true);
  14821. }
  14822. });
  14823. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14824. if (_this._tooltipFade) {
  14825. _this._tooltipFade.fadeIn(false);
  14826. }
  14827. });
  14828. }
  14829. if (this._tooltipTextBlock) {
  14830. this._tooltipTextBlock.text = text;
  14831. }
  14832. },
  14833. enumerable: false,
  14834. configurable: true
  14835. });
  14836. Object.defineProperty(HolographicButton.prototype, "text", {
  14837. /**
  14838. * Gets or sets text for the button
  14839. */
  14840. get: function () {
  14841. return this._text;
  14842. },
  14843. set: function (value) {
  14844. if (this._text === value) {
  14845. return;
  14846. }
  14847. this._text = value;
  14848. this._rebuildContent();
  14849. },
  14850. enumerable: false,
  14851. configurable: true
  14852. });
  14853. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14854. /**
  14855. * Gets or sets the image url for the button
  14856. */
  14857. get: function () {
  14858. return this._imageUrl;
  14859. },
  14860. set: function (value) {
  14861. if (this._imageUrl === value) {
  14862. return;
  14863. }
  14864. this._imageUrl = value;
  14865. this._rebuildContent();
  14866. },
  14867. enumerable: false,
  14868. configurable: true
  14869. });
  14870. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14871. /**
  14872. * Gets the back material used by this button
  14873. */
  14874. get: function () {
  14875. return this._backMaterial;
  14876. },
  14877. enumerable: false,
  14878. configurable: true
  14879. });
  14880. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14881. /**
  14882. * Gets the front material used by this button
  14883. */
  14884. get: function () {
  14885. return this._frontMaterial;
  14886. },
  14887. enumerable: false,
  14888. configurable: true
  14889. });
  14890. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14891. /**
  14892. * Gets the plate material used by this button
  14893. */
  14894. get: function () {
  14895. return this._plateMaterial;
  14896. },
  14897. enumerable: false,
  14898. configurable: true
  14899. });
  14900. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14901. /**
  14902. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14903. */
  14904. get: function () {
  14905. return this._shareMaterials;
  14906. },
  14907. enumerable: false,
  14908. configurable: true
  14909. });
  14910. HolographicButton.prototype._getTypeName = function () {
  14911. return "HolographicButton";
  14912. };
  14913. HolographicButton.prototype._rebuildContent = function () {
  14914. this._disposeFacadeTexture();
  14915. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14916. panel.isVertical = true;
  14917. if (this._imageUrl) {
  14918. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14919. image.source = this._imageUrl;
  14920. image.paddingTop = "40px";
  14921. image.height = "180px";
  14922. image.width = "100px";
  14923. image.paddingBottom = "40px";
  14924. panel.addControl(image);
  14925. }
  14926. if (this._text) {
  14927. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14928. text.text = this._text;
  14929. text.color = "white";
  14930. text.height = "30px";
  14931. text.fontSize = 24;
  14932. panel.addControl(text);
  14933. }
  14934. if (this._frontPlate) {
  14935. this.content = panel;
  14936. }
  14937. };
  14938. // Mesh association
  14939. HolographicButton.prototype._createNode = function (scene) {
  14940. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14941. width: 1.0,
  14942. height: 1.0,
  14943. depth: 0.08
  14944. }, scene);
  14945. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14946. width: 1.0,
  14947. height: 1.0,
  14948. depth: 0.08
  14949. }, scene);
  14950. this._frontPlate.parent = this._backPlate;
  14951. this._frontPlate.position.z = -0.08;
  14952. this._frontPlate.isPickable = false;
  14953. this._frontPlate.setEnabled(false);
  14954. this._textPlate = _super.prototype._createNode.call(this, scene);
  14955. this._textPlate.parent = this._backPlate;
  14956. this._textPlate.position.z = -0.08;
  14957. this._textPlate.isPickable = false;
  14958. return this._backPlate;
  14959. };
  14960. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14961. this._plateMaterial.emissiveTexture = facadeTexture;
  14962. this._plateMaterial.opacityTexture = facadeTexture;
  14963. };
  14964. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14965. var _this = this;
  14966. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14967. this._backMaterial.renderHoverLight = true;
  14968. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14969. if (pickedPoint) {
  14970. _this._backMaterial.hoverPosition = pickedPoint;
  14971. _this._backMaterial.hoverColor.a = 1.0;
  14972. }
  14973. else {
  14974. _this._backMaterial.hoverColor.a = 0;
  14975. }
  14976. });
  14977. };
  14978. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14979. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14980. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14981. this._frontMaterial.alpha = 0.5; // Additive
  14982. this._frontMaterial.renderBorders = true;
  14983. };
  14984. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14985. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14986. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14987. };
  14988. HolographicButton.prototype._affectMaterial = function (mesh) {
  14989. // Back
  14990. if (this._shareMaterials) {
  14991. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14992. this._createBackMaterial(mesh);
  14993. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14994. }
  14995. else {
  14996. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14997. }
  14998. // Front
  14999. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  15000. this._createFrontMaterial(mesh);
  15001. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  15002. }
  15003. else {
  15004. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  15005. }
  15006. }
  15007. else {
  15008. this._createBackMaterial(mesh);
  15009. this._createFrontMaterial(mesh);
  15010. }
  15011. this._createPlateMaterial(mesh);
  15012. this._backPlate.material = this._backMaterial;
  15013. this._frontPlate.material = this._frontMaterial;
  15014. this._textPlate.material = this._plateMaterial;
  15015. this._rebuildContent();
  15016. };
  15017. /**
  15018. * Releases all associated resources
  15019. */
  15020. HolographicButton.prototype.dispose = function () {
  15021. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  15022. this._disposeTooltip();
  15023. if (!this.shareMaterials) {
  15024. this._backMaterial.dispose();
  15025. this._frontMaterial.dispose();
  15026. this._plateMaterial.dispose();
  15027. if (this._pickedPointObserver) {
  15028. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  15029. this._pickedPointObserver = null;
  15030. }
  15031. }
  15032. };
  15033. return HolographicButton;
  15034. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15035. /***/ }),
  15036. /***/ "./3D/controls/index.ts":
  15037. /*!******************************!*\
  15038. !*** ./3D/controls/index.ts ***!
  15039. \******************************/
  15040. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15042. "use strict";
  15043. __webpack_require__.r(__webpack_exports__);
  15044. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15046. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15048. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15050. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15052. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15054. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15056. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15058. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15060. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15062. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15064. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15066. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15068. /***/ }),
  15069. /***/ "./3D/controls/meshButton3D.ts":
  15070. /*!*************************************!*\
  15071. !*** ./3D/controls/meshButton3D.ts ***!
  15072. \*************************************/
  15073. /*! exports provided: MeshButton3D */
  15074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15075. "use strict";
  15076. __webpack_require__.r(__webpack_exports__);
  15077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15078. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15079. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15080. /**
  15081. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15082. */
  15083. var MeshButton3D = /** @class */ (function (_super) {
  15084. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15085. /**
  15086. * Creates a new 3D button based on a mesh
  15087. * @param mesh mesh to become a 3D button
  15088. * @param name defines the control name
  15089. */
  15090. function MeshButton3D(mesh, name) {
  15091. var _this = _super.call(this, name) || this;
  15092. _this._currentMesh = mesh;
  15093. /**
  15094. * Provides a default behavior on hover/out & up/down
  15095. * Override those function to create your own desired behavior specific to your mesh
  15096. */
  15097. _this.pointerEnterAnimation = function () {
  15098. if (!_this.mesh) {
  15099. return;
  15100. }
  15101. _this.mesh.scaling.scaleInPlace(1.1);
  15102. };
  15103. _this.pointerOutAnimation = function () {
  15104. if (!_this.mesh) {
  15105. return;
  15106. }
  15107. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15108. };
  15109. _this.pointerDownAnimation = function () {
  15110. if (!_this.mesh) {
  15111. return;
  15112. }
  15113. _this.mesh.scaling.scaleInPlace(0.95);
  15114. };
  15115. _this.pointerUpAnimation = function () {
  15116. if (!_this.mesh) {
  15117. return;
  15118. }
  15119. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15120. };
  15121. return _this;
  15122. }
  15123. MeshButton3D.prototype._getTypeName = function () {
  15124. return "MeshButton3D";
  15125. };
  15126. // Mesh association
  15127. MeshButton3D.prototype._createNode = function (scene) {
  15128. var _this = this;
  15129. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15130. mesh.metadata = _this;
  15131. });
  15132. return this._currentMesh;
  15133. };
  15134. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15135. };
  15136. return MeshButton3D;
  15137. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15138. /***/ }),
  15139. /***/ "./3D/controls/planePanel.ts":
  15140. /*!***********************************!*\
  15141. !*** ./3D/controls/planePanel.ts ***!
  15142. \***********************************/
  15143. /*! exports provided: PlanePanel */
  15144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15145. "use strict";
  15146. __webpack_require__.r(__webpack_exports__);
  15147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15148. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15149. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  15150. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15151. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15152. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15153. /**
  15154. * Class used to create a container panel deployed on the surface of a plane
  15155. */
  15156. var PlanePanel = /** @class */ (function (_super) {
  15157. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15158. function PlanePanel() {
  15159. return _super !== null && _super.apply(this, arguments) || this;
  15160. }
  15161. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15162. var mesh = control.mesh;
  15163. if (!mesh) {
  15164. return;
  15165. }
  15166. control.position = nodePosition.clone();
  15167. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15168. target.copyFrom(nodePosition);
  15169. switch (this.orientation) {
  15170. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15171. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15172. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15173. mesh.lookAt(target);
  15174. break;
  15175. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15176. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15177. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15178. mesh.lookAt(target);
  15179. break;
  15180. }
  15181. };
  15182. return PlanePanel;
  15183. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15184. /***/ }),
  15185. /***/ "./3D/controls/scatterPanel.ts":
  15186. /*!*************************************!*\
  15187. !*** ./3D/controls/scatterPanel.ts ***!
  15188. \*************************************/
  15189. /*! exports provided: ScatterPanel */
  15190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15191. "use strict";
  15192. __webpack_require__.r(__webpack_exports__);
  15193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15195. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15196. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15197. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15198. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15199. /**
  15200. * Class used to create a container panel where items get randomized planar mapping
  15201. */
  15202. var ScatterPanel = /** @class */ (function (_super) {
  15203. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15204. function ScatterPanel() {
  15205. var _this = _super !== null && _super.apply(this, arguments) || this;
  15206. _this._iteration = 100.0;
  15207. return _this;
  15208. }
  15209. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15210. /**
  15211. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15212. */
  15213. get: function () {
  15214. return this._iteration;
  15215. },
  15216. set: function (value) {
  15217. var _this = this;
  15218. if (this._iteration === value) {
  15219. return;
  15220. }
  15221. this._iteration = value;
  15222. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15223. _this._arrangeChildren();
  15224. });
  15225. },
  15226. enumerable: false,
  15227. configurable: true
  15228. });
  15229. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15230. var mesh = control.mesh;
  15231. var newPos = this._scatterMapping(nodePosition);
  15232. if (!mesh) {
  15233. return;
  15234. }
  15235. switch (this.orientation) {
  15236. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15237. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15238. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15239. break;
  15240. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15241. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15242. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15243. break;
  15244. }
  15245. control.position = newPos;
  15246. };
  15247. ScatterPanel.prototype._scatterMapping = function (source) {
  15248. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15249. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15250. return source;
  15251. };
  15252. ScatterPanel.prototype._finalProcessing = function () {
  15253. var meshes = [];
  15254. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15255. var child = _a[_i];
  15256. if (!child.mesh) {
  15257. continue;
  15258. }
  15259. meshes.push(child.mesh);
  15260. }
  15261. for (var count = 0; count < this._iteration; count++) {
  15262. meshes.sort(function (a, b) {
  15263. var distance1 = a.position.lengthSquared();
  15264. var distance2 = b.position.lengthSquared();
  15265. if (distance1 < distance2) {
  15266. return 1;
  15267. }
  15268. else if (distance1 > distance2) {
  15269. return -1;
  15270. }
  15271. return 0;
  15272. });
  15273. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15274. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15275. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15276. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15277. for (var i = 0; i < meshes.length - 1; i++) {
  15278. for (var j = i + 1; j < meshes.length; j++) {
  15279. if (i != j) {
  15280. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15281. // Ignore Z axis
  15282. difference2D.x = difference.x;
  15283. difference2D.y = difference.y;
  15284. var combinedRadius = cellSize;
  15285. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15286. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15287. distance -= minSeparation;
  15288. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15289. difference2D.normalize();
  15290. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15291. meshes[j].position.addInPlace(difference);
  15292. meshes[i].position.subtractInPlace(difference);
  15293. }
  15294. }
  15295. }
  15296. }
  15297. }
  15298. };
  15299. return ScatterPanel;
  15300. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15301. /***/ }),
  15302. /***/ "./3D/controls/spherePanel.ts":
  15303. /*!************************************!*\
  15304. !*** ./3D/controls/spherePanel.ts ***!
  15305. \************************************/
  15306. /*! exports provided: SpherePanel */
  15307. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15308. "use strict";
  15309. __webpack_require__.r(__webpack_exports__);
  15310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15311. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15312. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15313. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15314. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15315. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15316. /**
  15317. * Class used to create a container panel deployed on the surface of a sphere
  15318. */
  15319. var SpherePanel = /** @class */ (function (_super) {
  15320. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15321. function SpherePanel() {
  15322. var _this = _super !== null && _super.apply(this, arguments) || this;
  15323. _this._radius = 5.0;
  15324. return _this;
  15325. }
  15326. Object.defineProperty(SpherePanel.prototype, "radius", {
  15327. /**
  15328. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15329. */
  15330. get: function () {
  15331. return this._radius;
  15332. },
  15333. set: function (value) {
  15334. var _this = this;
  15335. if (this._radius === value) {
  15336. return;
  15337. }
  15338. this._radius = value;
  15339. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15340. _this._arrangeChildren();
  15341. });
  15342. },
  15343. enumerable: false,
  15344. configurable: true
  15345. });
  15346. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15347. var mesh = control.mesh;
  15348. if (!mesh) {
  15349. return;
  15350. }
  15351. var newPos = this._sphericalMapping(nodePosition);
  15352. control.position = newPos;
  15353. switch (this.orientation) {
  15354. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15355. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15356. break;
  15357. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15358. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15359. break;
  15360. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15361. break;
  15362. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15363. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15364. break;
  15365. }
  15366. };
  15367. SpherePanel.prototype._sphericalMapping = function (source) {
  15368. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15369. var xAngle = (source.y / this._radius);
  15370. var yAngle = -(source.x / this._radius);
  15371. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15372. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15373. };
  15374. return SpherePanel;
  15375. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15376. /***/ }),
  15377. /***/ "./3D/controls/stackPanel3D.ts":
  15378. /*!*************************************!*\
  15379. !*** ./3D/controls/stackPanel3D.ts ***!
  15380. \*************************************/
  15381. /*! exports provided: StackPanel3D */
  15382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15383. "use strict";
  15384. __webpack_require__.r(__webpack_exports__);
  15385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15386. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15387. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15388. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15389. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15390. /**
  15391. * Class used to create a stack panel in 3D on XY plane
  15392. */
  15393. var StackPanel3D = /** @class */ (function (_super) {
  15394. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15395. /**
  15396. * Creates new StackPanel
  15397. * @param isVertical
  15398. */
  15399. function StackPanel3D(isVertical) {
  15400. if (isVertical === void 0) { isVertical = false; }
  15401. var _this = _super.call(this) || this;
  15402. _this._isVertical = false;
  15403. /**
  15404. * Gets or sets the distance between elements
  15405. */
  15406. _this.margin = 0.1;
  15407. _this._isVertical = isVertical;
  15408. return _this;
  15409. }
  15410. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15411. /**
  15412. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15413. */
  15414. get: function () {
  15415. return this._isVertical;
  15416. },
  15417. set: function (value) {
  15418. var _this = this;
  15419. if (this._isVertical === value) {
  15420. return;
  15421. }
  15422. this._isVertical = value;
  15423. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15424. _this._arrangeChildren();
  15425. });
  15426. },
  15427. enumerable: false,
  15428. configurable: true
  15429. });
  15430. StackPanel3D.prototype._arrangeChildren = function () {
  15431. var width = 0;
  15432. var height = 0;
  15433. var controlCount = 0;
  15434. var extendSizes = [];
  15435. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15436. // Measure
  15437. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15438. var child = _a[_i];
  15439. if (!child.mesh) {
  15440. continue;
  15441. }
  15442. controlCount++;
  15443. child.mesh.computeWorldMatrix(true);
  15444. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15445. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15446. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15447. extendSizes.push(extendSize);
  15448. if (this._isVertical) {
  15449. height += extendSize.y;
  15450. }
  15451. else {
  15452. width += extendSize.x;
  15453. }
  15454. }
  15455. if (this._isVertical) {
  15456. height += (controlCount - 1) * this.margin / 2;
  15457. }
  15458. else {
  15459. width += (controlCount - 1) * this.margin / 2;
  15460. }
  15461. // Arrange
  15462. var offset;
  15463. if (this._isVertical) {
  15464. offset = -height;
  15465. }
  15466. else {
  15467. offset = -width;
  15468. }
  15469. var index = 0;
  15470. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15471. var child = _c[_b];
  15472. if (!child.mesh) {
  15473. continue;
  15474. }
  15475. controlCount--;
  15476. var extendSize = extendSizes[index++];
  15477. if (this._isVertical) {
  15478. child.position.y = offset + extendSize.y;
  15479. child.position.x = 0;
  15480. offset += extendSize.y * 2;
  15481. }
  15482. else {
  15483. child.position.x = offset + extendSize.x;
  15484. child.position.y = 0;
  15485. offset += extendSize.x * 2;
  15486. }
  15487. offset += (controlCount > 0 ? this.margin : 0);
  15488. }
  15489. };
  15490. return StackPanel3D;
  15491. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15492. /***/ }),
  15493. /***/ "./3D/controls/volumeBasedPanel.ts":
  15494. /*!*****************************************!*\
  15495. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15496. \*****************************************/
  15497. /*! exports provided: VolumeBasedPanel */
  15498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15499. "use strict";
  15500. __webpack_require__.r(__webpack_exports__);
  15501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15502. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15503. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15504. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15505. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15506. /**
  15507. * Abstract class used to create a container panel deployed on the surface of a volume
  15508. */
  15509. var VolumeBasedPanel = /** @class */ (function (_super) {
  15510. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15511. /**
  15512. * Creates new VolumeBasedPanel
  15513. */
  15514. function VolumeBasedPanel() {
  15515. var _this = _super.call(this) || this;
  15516. _this._columns = 10;
  15517. _this._rows = 0;
  15518. _this._rowThenColum = true;
  15519. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15520. /**
  15521. * Gets or sets the distance between elements
  15522. */
  15523. _this.margin = 0;
  15524. return _this;
  15525. }
  15526. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15527. /**
  15528. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15529. * | Value | Type | Description |
  15530. * | ----- | ----------------------------------- | ----------- |
  15531. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15532. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15533. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15534. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15535. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15536. */
  15537. get: function () {
  15538. return this._orientation;
  15539. },
  15540. set: function (value) {
  15541. var _this = this;
  15542. if (this._orientation === value) {
  15543. return;
  15544. }
  15545. this._orientation = value;
  15546. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15547. _this._arrangeChildren();
  15548. });
  15549. },
  15550. enumerable: false,
  15551. configurable: true
  15552. });
  15553. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15554. /**
  15555. * Gets or sets the number of columns requested (10 by default).
  15556. * The panel will automatically compute the number of rows based on number of child controls.
  15557. */
  15558. get: function () {
  15559. return this._columns;
  15560. },
  15561. set: function (value) {
  15562. var _this = this;
  15563. if (this._columns === value) {
  15564. return;
  15565. }
  15566. this._columns = value;
  15567. this._rowThenColum = true;
  15568. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15569. _this._arrangeChildren();
  15570. });
  15571. },
  15572. enumerable: false,
  15573. configurable: true
  15574. });
  15575. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15576. /**
  15577. * Gets or sets a the number of rows requested.
  15578. * The panel will automatically compute the number of columns based on number of child controls.
  15579. */
  15580. get: function () {
  15581. return this._rows;
  15582. },
  15583. set: function (value) {
  15584. var _this = this;
  15585. if (this._rows === value) {
  15586. return;
  15587. }
  15588. this._rows = value;
  15589. this._rowThenColum = false;
  15590. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15591. _this._arrangeChildren();
  15592. });
  15593. },
  15594. enumerable: false,
  15595. configurable: true
  15596. });
  15597. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15598. this._cellWidth = 0;
  15599. this._cellHeight = 0;
  15600. var rows = 0;
  15601. var columns = 0;
  15602. var controlCount = 0;
  15603. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15604. // Measure
  15605. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15606. var child = _a[_i];
  15607. if (!child.mesh) {
  15608. continue;
  15609. }
  15610. controlCount++;
  15611. child.mesh.computeWorldMatrix(true);
  15612. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15613. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15614. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15615. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15616. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15617. diff.scaleInPlace(0.5);
  15618. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15619. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15620. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15621. }
  15622. this._cellWidth += this.margin * 2;
  15623. this._cellHeight += this.margin * 2;
  15624. // Arrange
  15625. if (this._rowThenColum) {
  15626. columns = this._columns;
  15627. rows = Math.ceil(controlCount / this._columns);
  15628. }
  15629. else {
  15630. rows = this._rows;
  15631. columns = Math.ceil(controlCount / this._rows);
  15632. }
  15633. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15634. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15635. var nodeGrid = [];
  15636. var cellCounter = 0;
  15637. if (this._rowThenColum) {
  15638. for (var r = 0; r < rows; r++) {
  15639. for (var c = 0; c < columns; c++) {
  15640. 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));
  15641. cellCounter++;
  15642. if (cellCounter > controlCount) {
  15643. break;
  15644. }
  15645. }
  15646. }
  15647. }
  15648. else {
  15649. for (var c = 0; c < columns; c++) {
  15650. for (var r = 0; r < rows; r++) {
  15651. 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));
  15652. cellCounter++;
  15653. if (cellCounter > controlCount) {
  15654. break;
  15655. }
  15656. }
  15657. }
  15658. }
  15659. cellCounter = 0;
  15660. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15661. var child = _c[_b];
  15662. if (!child.mesh) {
  15663. continue;
  15664. }
  15665. this._mapGridNode(child, nodeGrid[cellCounter]);
  15666. cellCounter++;
  15667. }
  15668. this._finalProcessing();
  15669. };
  15670. /** Child classes can implement this function to provide additional processing */
  15671. VolumeBasedPanel.prototype._finalProcessing = function () {
  15672. };
  15673. return VolumeBasedPanel;
  15674. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15675. /***/ }),
  15676. /***/ "./3D/gui3DManager.ts":
  15677. /*!****************************!*\
  15678. !*** ./3D/gui3DManager.ts ***!
  15679. \****************************/
  15680. /*! exports provided: GUI3DManager */
  15681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15682. "use strict";
  15683. __webpack_require__.r(__webpack_exports__);
  15684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15685. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15686. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15687. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15688. /**
  15689. * Class used to manage 3D user interface
  15690. * @see https://doc.babylonjs.com/how_to/gui3d
  15691. */
  15692. var GUI3DManager = /** @class */ (function () {
  15693. /**
  15694. * Creates a new GUI3DManager
  15695. * @param scene
  15696. */
  15697. function GUI3DManager(scene) {
  15698. var _this = this;
  15699. /** @hidden */
  15700. this._lastControlOver = {};
  15701. /** @hidden */
  15702. this._lastControlDown = {};
  15703. /**
  15704. * Observable raised when the point picked by the pointer events changed
  15705. */
  15706. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15707. // Shared resources
  15708. /** @hidden */
  15709. this._sharedMaterials = {};
  15710. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15711. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15712. _this._sceneDisposeObserver = null;
  15713. _this._utilityLayer = null;
  15714. _this.dispose();
  15715. });
  15716. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15717. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15718. this._utilityLayer.pickUtilitySceneFirst = false;
  15719. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15720. return mesh && mesh.metadata && mesh.metadata._node;
  15721. };
  15722. // Root
  15723. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15724. this._rootContainer._host = this;
  15725. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15726. // Events
  15727. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15728. _this._handlePointerOut(pointerId, true);
  15729. });
  15730. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15731. _this._doPicking(pi);
  15732. });
  15733. // Scene
  15734. this._utilityLayer.utilityLayerScene.autoClear = false;
  15735. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15736. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15737. }
  15738. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15739. /** Gets the hosting scene */
  15740. get: function () {
  15741. return this._scene;
  15742. },
  15743. enumerable: false,
  15744. configurable: true
  15745. });
  15746. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15747. /** Gets associated utility layer */
  15748. get: function () {
  15749. return this._utilityLayer;
  15750. },
  15751. enumerable: false,
  15752. configurable: true
  15753. });
  15754. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15755. var previousControlOver = this._lastControlOver[pointerId];
  15756. if (previousControlOver) {
  15757. previousControlOver._onPointerOut(previousControlOver);
  15758. delete this._lastControlOver[pointerId];
  15759. }
  15760. if (isPointerUp) {
  15761. if (this._lastControlDown[pointerId]) {
  15762. this._lastControlDown[pointerId].forcePointerUp();
  15763. delete this._lastControlDown[pointerId];
  15764. }
  15765. }
  15766. this.onPickedPointChangedObservable.notifyObservers(null);
  15767. };
  15768. GUI3DManager.prototype._doPicking = function (pi) {
  15769. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15770. return false;
  15771. }
  15772. var pointerEvent = (pi.event);
  15773. var pointerId = pointerEvent.pointerId || 0;
  15774. var buttonIndex = pointerEvent.button;
  15775. var pickingInfo = pi.pickInfo;
  15776. if (!pickingInfo || !pickingInfo.hit) {
  15777. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15778. return false;
  15779. }
  15780. var control = (pickingInfo.pickedMesh.metadata);
  15781. if (pickingInfo.pickedPoint) {
  15782. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15783. }
  15784. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15785. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15786. if (this._lastControlOver[pointerId]) {
  15787. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15788. }
  15789. delete this._lastControlOver[pointerId];
  15790. }
  15791. }
  15792. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15793. if (this._lastControlDown[pointerEvent.pointerId]) {
  15794. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15795. delete this._lastControlDown[pointerEvent.pointerId];
  15796. }
  15797. if (pointerEvent.pointerType === "touch") {
  15798. this._handlePointerOut(pointerId, false);
  15799. }
  15800. }
  15801. return true;
  15802. };
  15803. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15804. /**
  15805. * Gets the root container
  15806. */
  15807. get: function () {
  15808. return this._rootContainer;
  15809. },
  15810. enumerable: false,
  15811. configurable: true
  15812. });
  15813. /**
  15814. * Gets a boolean indicating if the given control is in the root child list
  15815. * @param control defines the control to check
  15816. * @returns true if the control is in the root child list
  15817. */
  15818. GUI3DManager.prototype.containsControl = function (control) {
  15819. return this._rootContainer.containsControl(control);
  15820. };
  15821. /**
  15822. * Adds a control to the root child list
  15823. * @param control defines the control to add
  15824. * @returns the current manager
  15825. */
  15826. GUI3DManager.prototype.addControl = function (control) {
  15827. this._rootContainer.addControl(control);
  15828. return this;
  15829. };
  15830. /**
  15831. * Removes a control from the root child list
  15832. * @param control defines the control to remove
  15833. * @returns the current container
  15834. */
  15835. GUI3DManager.prototype.removeControl = function (control) {
  15836. this._rootContainer.removeControl(control);
  15837. return this;
  15838. };
  15839. /**
  15840. * Releases all associated resources
  15841. */
  15842. GUI3DManager.prototype.dispose = function () {
  15843. this._rootContainer.dispose();
  15844. for (var materialName in this._sharedMaterials) {
  15845. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15846. continue;
  15847. }
  15848. this._sharedMaterials[materialName].dispose();
  15849. }
  15850. this._sharedMaterials = {};
  15851. if (this._pointerOutObserver && this._utilityLayer) {
  15852. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15853. this._pointerOutObserver = null;
  15854. }
  15855. this.onPickedPointChangedObservable.clear();
  15856. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15857. if (utilityLayerScene) {
  15858. if (this._pointerObserver) {
  15859. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15860. this._pointerObserver = null;
  15861. }
  15862. }
  15863. if (this._scene) {
  15864. if (this._sceneDisposeObserver) {
  15865. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15866. this._sceneDisposeObserver = null;
  15867. }
  15868. }
  15869. if (this._utilityLayer) {
  15870. this._utilityLayer.dispose();
  15871. }
  15872. };
  15873. return GUI3DManager;
  15874. }());
  15875. /***/ }),
  15876. /***/ "./3D/index.ts":
  15877. /*!*********************!*\
  15878. !*** ./3D/index.ts ***!
  15879. \*********************/
  15880. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  15881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15882. "use strict";
  15883. __webpack_require__.r(__webpack_exports__);
  15884. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15897. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15900. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15902. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15904. /***/ }),
  15905. /***/ "./3D/materials/fluentMaterial.ts":
  15906. /*!****************************************!*\
  15907. !*** ./3D/materials/fluentMaterial.ts ***!
  15908. \****************************************/
  15909. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15911. "use strict";
  15912. __webpack_require__.r(__webpack_exports__);
  15913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15915. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15916. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15917. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15918. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15919. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15920. /** @hidden */
  15921. var FluentMaterialDefines = /** @class */ (function (_super) {
  15922. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15923. function FluentMaterialDefines() {
  15924. var _this = _super.call(this) || this;
  15925. _this.INNERGLOW = false;
  15926. _this.BORDER = false;
  15927. _this.HOVERLIGHT = false;
  15928. _this.TEXTURE = false;
  15929. _this.rebuild();
  15930. return _this;
  15931. }
  15932. return FluentMaterialDefines;
  15933. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15934. /**
  15935. * Class used to render controls with fluent desgin
  15936. */
  15937. var FluentMaterial = /** @class */ (function (_super) {
  15938. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15939. /**
  15940. * Creates a new Fluent material
  15941. * @param name defines the name of the material
  15942. * @param scene defines the hosting scene
  15943. */
  15944. function FluentMaterial(name, scene) {
  15945. var _this = _super.call(this, name, scene) || this;
  15946. /**
  15947. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15948. */
  15949. _this.innerGlowColorIntensity = 0.5;
  15950. /**
  15951. * Gets or sets the inner glow color (white by default)
  15952. */
  15953. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15954. /**
  15955. * Gets or sets alpha value (default is 1.0)
  15956. */
  15957. _this.alpha = 1.0;
  15958. /**
  15959. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15960. */
  15961. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15962. /**
  15963. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15964. */
  15965. _this.renderBorders = false;
  15966. /**
  15967. * Gets or sets border width (default is 0.5)
  15968. */
  15969. _this.borderWidth = 0.5;
  15970. /**
  15971. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15972. */
  15973. _this.edgeSmoothingValue = 0.02;
  15974. /**
  15975. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15976. */
  15977. _this.borderMinValue = 0.1;
  15978. /**
  15979. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15980. */
  15981. _this.renderHoverLight = false;
  15982. /**
  15983. * Gets or sets the radius used to render the hover light (default is 1.0)
  15984. */
  15985. _this.hoverRadius = 1.0;
  15986. /**
  15987. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15988. */
  15989. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15990. /**
  15991. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15992. */
  15993. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15994. return _this;
  15995. }
  15996. FluentMaterial.prototype.needAlphaBlending = function () {
  15997. return this.alpha !== 1.0;
  15998. };
  15999. FluentMaterial.prototype.needAlphaTesting = function () {
  16000. return false;
  16001. };
  16002. FluentMaterial.prototype.getAlphaTestTexture = function () {
  16003. return null;
  16004. };
  16005. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  16006. if (this.isFrozen) {
  16007. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  16008. return true;
  16009. }
  16010. }
  16011. if (!subMesh._materialDefines) {
  16012. subMesh._materialDefines = new FluentMaterialDefines();
  16013. }
  16014. var scene = this.getScene();
  16015. var defines = subMesh._materialDefines;
  16016. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  16017. if (defines._renderId === scene.getRenderId()) {
  16018. return true;
  16019. }
  16020. }
  16021. if (defines._areTexturesDirty) {
  16022. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  16023. defines.BORDER = this.renderBorders;
  16024. defines.HOVERLIGHT = this.renderHoverLight;
  16025. if (this._albedoTexture) {
  16026. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  16027. return false;
  16028. }
  16029. else {
  16030. defines.TEXTURE = true;
  16031. }
  16032. }
  16033. else {
  16034. defines.TEXTURE = false;
  16035. }
  16036. }
  16037. var engine = scene.getEngine();
  16038. // Get correct effect
  16039. if (defines.isDirty) {
  16040. defines.markAsProcessed();
  16041. scene.resetCachedMaterial();
  16042. //Attributes
  16043. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16044. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16045. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16046. var shaderName = "fluent";
  16047. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16048. "hoverColor", "hoverPosition", "hoverRadius"
  16049. ];
  16050. var samplers = ["albedoSampler"];
  16051. var uniformBuffers = new Array();
  16052. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16053. uniformsNames: uniforms,
  16054. uniformBuffersNames: uniformBuffers,
  16055. samplers: samplers,
  16056. defines: defines,
  16057. maxSimultaneousLights: 4
  16058. });
  16059. var join = defines.toString();
  16060. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16061. attributes: attribs,
  16062. uniformsNames: uniforms,
  16063. uniformBuffersNames: uniformBuffers,
  16064. samplers: samplers,
  16065. defines: join,
  16066. fallbacks: null,
  16067. onCompiled: this.onCompiled,
  16068. onError: this.onError,
  16069. indexParameters: { maxSimultaneousLights: 4 }
  16070. }, engine));
  16071. }
  16072. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16073. return false;
  16074. }
  16075. defines._renderId = scene.getRenderId();
  16076. subMesh.effect._wasPreviouslyReady = true;
  16077. return true;
  16078. };
  16079. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16080. var scene = this.getScene();
  16081. var defines = subMesh._materialDefines;
  16082. if (!defines) {
  16083. return;
  16084. }
  16085. var effect = subMesh.effect;
  16086. if (!effect) {
  16087. return;
  16088. }
  16089. this._activeEffect = effect;
  16090. // Matrices
  16091. this.bindOnlyWorldMatrix(world);
  16092. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16093. if (this._mustRebind(scene, effect)) {
  16094. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16095. if (defines.INNERGLOW) {
  16096. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16097. }
  16098. if (defines.BORDER) {
  16099. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16100. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16101. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16102. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16103. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16104. }
  16105. if (defines.HOVERLIGHT) {
  16106. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16107. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16108. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16109. }
  16110. if (defines.TEXTURE) {
  16111. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16112. }
  16113. }
  16114. this._afterBind(mesh, this._activeEffect);
  16115. };
  16116. FluentMaterial.prototype.getActiveTextures = function () {
  16117. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16118. return activeTextures;
  16119. };
  16120. FluentMaterial.prototype.hasTexture = function (texture) {
  16121. if (_super.prototype.hasTexture.call(this, texture)) {
  16122. return true;
  16123. }
  16124. return false;
  16125. };
  16126. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16127. _super.prototype.dispose.call(this, forceDisposeEffect);
  16128. };
  16129. FluentMaterial.prototype.clone = function (name) {
  16130. var _this = this;
  16131. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16132. };
  16133. FluentMaterial.prototype.serialize = function () {
  16134. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16135. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16136. return serializationObject;
  16137. };
  16138. FluentMaterial.prototype.getClassName = function () {
  16139. return "FluentMaterial";
  16140. };
  16141. // Statics
  16142. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16143. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16144. };
  16145. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16146. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16147. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16148. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16149. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16150. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16151. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16152. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16153. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16154. ], FluentMaterial.prototype, "alpha", void 0);
  16155. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16156. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16157. ], FluentMaterial.prototype, "albedoColor", void 0);
  16158. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16159. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16160. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16161. ], FluentMaterial.prototype, "renderBorders", void 0);
  16162. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16163. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16164. ], FluentMaterial.prototype, "borderWidth", void 0);
  16165. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16166. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16167. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16168. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16169. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16170. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16171. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16172. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16173. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16174. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16175. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16176. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16177. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16178. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16179. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16180. ], FluentMaterial.prototype, "hoverColor", void 0);
  16181. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16182. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16183. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16184. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16185. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16186. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16187. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16188. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16189. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16190. return FluentMaterial;
  16191. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16192. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16193. /***/ }),
  16194. /***/ "./3D/materials/index.ts":
  16195. /*!*******************************!*\
  16196. !*** ./3D/materials/index.ts ***!
  16197. \*******************************/
  16198. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16200. "use strict";
  16201. __webpack_require__.r(__webpack_exports__);
  16202. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16205. /***/ }),
  16206. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16207. /*!*************************************************!*\
  16208. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16209. \*************************************************/
  16210. /*! exports provided: fluentPixelShader */
  16211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16212. "use strict";
  16213. __webpack_require__.r(__webpack_exports__);
  16214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16215. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16216. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16217. var name = 'fluentPixelShader';
  16218. 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}";
  16219. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16220. /** @hidden */
  16221. var fluentPixelShader = { name: name, shader: shader };
  16222. /***/ }),
  16223. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16224. /*!***********************************************!*\
  16225. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16226. \***********************************************/
  16227. /*! exports provided: fluentVertexShader */
  16228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16229. "use strict";
  16230. __webpack_require__.r(__webpack_exports__);
  16231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16232. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16233. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16234. var name = 'fluentVertexShader';
  16235. 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";
  16236. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16237. /** @hidden */
  16238. var fluentVertexShader = { name: name, shader: shader };
  16239. /***/ }),
  16240. /***/ "./3D/vector3WithInfo.ts":
  16241. /*!*******************************!*\
  16242. !*** ./3D/vector3WithInfo.ts ***!
  16243. \*******************************/
  16244. /*! exports provided: Vector3WithInfo */
  16245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16246. "use strict";
  16247. __webpack_require__.r(__webpack_exports__);
  16248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16249. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16250. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/perfCounter");
  16251. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16252. /**
  16253. * Class used to transport Vector3 information for pointer events
  16254. */
  16255. var Vector3WithInfo = /** @class */ (function (_super) {
  16256. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16257. /**
  16258. * Creates a new Vector3WithInfo
  16259. * @param source defines the vector3 data to transport
  16260. * @param buttonIndex defines the current mouse button index
  16261. */
  16262. function Vector3WithInfo(source,
  16263. /** defines the current mouse button index */
  16264. buttonIndex) {
  16265. if (buttonIndex === void 0) { buttonIndex = 0; }
  16266. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16267. _this.buttonIndex = buttonIndex;
  16268. return _this;
  16269. }
  16270. return Vector3WithInfo;
  16271. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16272. /***/ }),
  16273. /***/ "./index.ts":
  16274. /*!******************!*\
  16275. !*** ./index.ts ***!
  16276. \******************/
  16277. /*! 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 */
  16278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16279. "use strict";
  16280. __webpack_require__.r(__webpack_exports__);
  16281. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16323. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16340. /***/ }),
  16341. /***/ "./legacy/legacy.ts":
  16342. /*!**************************!*\
  16343. !*** ./legacy/legacy.ts ***!
  16344. \**************************/
  16345. /*! 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 */
  16346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16347. "use strict";
  16348. __webpack_require__.r(__webpack_exports__);
  16349. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16407. /**
  16408. * Legacy support, defining window.BABYLON.GUI (global variable).
  16409. *
  16410. * This is the entry point for the UMD module.
  16411. * The entry point for a future ESM package should be index.ts
  16412. */
  16413. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16414. if (typeof globalObject !== "undefined") {
  16415. globalObject.BABYLON = globalObject.BABYLON || {};
  16416. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16417. }
  16418. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16419. /***/ }),
  16420. /***/ "babylonjs/Misc/perfCounter":
  16421. /*!****************************************************************************************************!*\
  16422. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16423. \****************************************************************************************************/
  16424. /*! no static exports found */
  16425. /***/ (function(module, exports) {
  16426. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  16427. /***/ })
  16428. /******/ });
  16429. });
  16430. //# sourceMappingURL=babylon.gui.js.map