babylon.gui.js 754 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** 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/Maths/math.vector");
  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/Maths/math.vector");
  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/Maths/math.vector");
  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/Maths/math.vector");
  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/Maths/math.vector");
  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/Maths/math.vector");
  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/Maths/math.vector");
  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. /**
  3787. * Gets or sets a fixed ratio for this control.
  3788. * When different from 0, the ratio is used to compute the "second" dimension.
  3789. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3790. * second dimension is computed as first dimension * fixedRatio
  3791. */
  3792. this.fixedRatio = 0;
  3793. this._fixedRatioMasterIsWidth = true;
  3794. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3795. }
  3796. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3797. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3798. get: function () {
  3799. return this._shadowOffsetX;
  3800. },
  3801. set: function (value) {
  3802. if (this._shadowOffsetX === value) {
  3803. return;
  3804. }
  3805. this._shadowOffsetX = value;
  3806. this._markAsDirty();
  3807. },
  3808. enumerable: false,
  3809. configurable: true
  3810. });
  3811. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3812. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3813. get: function () {
  3814. return this._shadowOffsetY;
  3815. },
  3816. set: function (value) {
  3817. if (this._shadowOffsetY === value) {
  3818. return;
  3819. }
  3820. this._shadowOffsetY = value;
  3821. this._markAsDirty();
  3822. },
  3823. enumerable: false,
  3824. configurable: true
  3825. });
  3826. Object.defineProperty(Control.prototype, "shadowBlur", {
  3827. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3828. get: function () {
  3829. return this._shadowBlur;
  3830. },
  3831. set: function (value) {
  3832. if (this._shadowBlur === value) {
  3833. return;
  3834. }
  3835. this._shadowBlur = value;
  3836. this._markAsDirty();
  3837. },
  3838. enumerable: false,
  3839. configurable: true
  3840. });
  3841. Object.defineProperty(Control.prototype, "shadowColor", {
  3842. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3843. get: function () {
  3844. return this._shadowColor;
  3845. },
  3846. set: function (value) {
  3847. if (this._shadowColor === value) {
  3848. return;
  3849. }
  3850. this._shadowColor = value;
  3851. this._markAsDirty();
  3852. },
  3853. enumerable: false,
  3854. configurable: true
  3855. });
  3856. Object.defineProperty(Control.prototype, "typeName", {
  3857. // Properties
  3858. /** Gets the control type name */
  3859. get: function () {
  3860. return this._getTypeName();
  3861. },
  3862. enumerable: false,
  3863. configurable: true
  3864. });
  3865. /**
  3866. * Get the current class name of the control.
  3867. * @returns current class name
  3868. */
  3869. Control.prototype.getClassName = function () {
  3870. return this._getTypeName();
  3871. };
  3872. Object.defineProperty(Control.prototype, "host", {
  3873. /**
  3874. * Get the hosting AdvancedDynamicTexture
  3875. */
  3876. get: function () {
  3877. return this._host;
  3878. },
  3879. enumerable: false,
  3880. configurable: true
  3881. });
  3882. Object.defineProperty(Control.prototype, "fontOffset", {
  3883. /** Gets or set information about font offsets (used to render and align text) */
  3884. get: function () {
  3885. return this._fontOffset;
  3886. },
  3887. set: function (offset) {
  3888. this._fontOffset = offset;
  3889. },
  3890. enumerable: false,
  3891. configurable: true
  3892. });
  3893. Object.defineProperty(Control.prototype, "alpha", {
  3894. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3895. get: function () {
  3896. return this._alpha;
  3897. },
  3898. set: function (value) {
  3899. if (this._alpha === value) {
  3900. return;
  3901. }
  3902. this._alphaSet = true;
  3903. this._alpha = value;
  3904. this._markAsDirty();
  3905. },
  3906. enumerable: false,
  3907. configurable: true
  3908. });
  3909. Object.defineProperty(Control.prototype, "isHighlighted", {
  3910. /**
  3911. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3912. */
  3913. get: function () {
  3914. return this._isHighlighted;
  3915. },
  3916. set: function (value) {
  3917. if (this._isHighlighted === value) {
  3918. return;
  3919. }
  3920. this._isHighlighted = value;
  3921. this._markAsDirty();
  3922. },
  3923. enumerable: false,
  3924. configurable: true
  3925. });
  3926. Object.defineProperty(Control.prototype, "scaleX", {
  3927. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3928. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3929. */
  3930. get: function () {
  3931. return this._scaleX;
  3932. },
  3933. set: function (value) {
  3934. if (this._scaleX === value) {
  3935. return;
  3936. }
  3937. this._scaleX = value;
  3938. this._markAsDirty();
  3939. this._markMatrixAsDirty();
  3940. },
  3941. enumerable: false,
  3942. configurable: true
  3943. });
  3944. Object.defineProperty(Control.prototype, "scaleY", {
  3945. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3946. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3947. */
  3948. get: function () {
  3949. return this._scaleY;
  3950. },
  3951. set: function (value) {
  3952. if (this._scaleY === value) {
  3953. return;
  3954. }
  3955. this._scaleY = value;
  3956. this._markAsDirty();
  3957. this._markMatrixAsDirty();
  3958. },
  3959. enumerable: false,
  3960. configurable: true
  3961. });
  3962. Object.defineProperty(Control.prototype, "rotation", {
  3963. /** Gets or sets the rotation angle (0 by default)
  3964. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3965. */
  3966. get: function () {
  3967. return this._rotation;
  3968. },
  3969. set: function (value) {
  3970. if (this._rotation === value) {
  3971. return;
  3972. }
  3973. this._rotation = value;
  3974. this._markAsDirty();
  3975. this._markMatrixAsDirty();
  3976. },
  3977. enumerable: false,
  3978. configurable: true
  3979. });
  3980. Object.defineProperty(Control.prototype, "transformCenterY", {
  3981. /** Gets or sets the transformation center on Y axis (0 by default)
  3982. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3983. */
  3984. get: function () {
  3985. return this._transformCenterY;
  3986. },
  3987. set: function (value) {
  3988. if (this._transformCenterY === value) {
  3989. return;
  3990. }
  3991. this._transformCenterY = value;
  3992. this._markAsDirty();
  3993. this._markMatrixAsDirty();
  3994. },
  3995. enumerable: false,
  3996. configurable: true
  3997. });
  3998. Object.defineProperty(Control.prototype, "transformCenterX", {
  3999. /** Gets or sets the transformation center on X axis (0 by default)
  4000. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4001. */
  4002. get: function () {
  4003. return this._transformCenterX;
  4004. },
  4005. set: function (value) {
  4006. if (this._transformCenterX === value) {
  4007. return;
  4008. }
  4009. this._transformCenterX = value;
  4010. this._markAsDirty();
  4011. this._markMatrixAsDirty();
  4012. },
  4013. enumerable: false,
  4014. configurable: true
  4015. });
  4016. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4017. /**
  4018. * Gets or sets the horizontal alignment
  4019. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4020. */
  4021. get: function () {
  4022. return this._horizontalAlignment;
  4023. },
  4024. set: function (value) {
  4025. if (this._horizontalAlignment === value) {
  4026. return;
  4027. }
  4028. this._horizontalAlignment = value;
  4029. this._markAsDirty();
  4030. },
  4031. enumerable: false,
  4032. configurable: true
  4033. });
  4034. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4035. /**
  4036. * Gets or sets the vertical alignment
  4037. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4038. */
  4039. get: function () {
  4040. return this._verticalAlignment;
  4041. },
  4042. set: function (value) {
  4043. if (this._verticalAlignment === value) {
  4044. return;
  4045. }
  4046. this._verticalAlignment = value;
  4047. this._markAsDirty();
  4048. },
  4049. enumerable: false,
  4050. configurable: true
  4051. });
  4052. Object.defineProperty(Control.prototype, "width", {
  4053. /**
  4054. * Gets or sets control width
  4055. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4056. */
  4057. get: function () {
  4058. return this._width.toString(this._host);
  4059. },
  4060. set: function (value) {
  4061. this._fixedRatioMasterIsWidth = true;
  4062. if (this._width.toString(this._host) === value) {
  4063. return;
  4064. }
  4065. if (this._width.fromString(value)) {
  4066. this._markAsDirty();
  4067. }
  4068. },
  4069. enumerable: false,
  4070. configurable: true
  4071. });
  4072. Object.defineProperty(Control.prototype, "widthInPixels", {
  4073. /**
  4074. * Gets or sets the control width in pixel
  4075. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4076. */
  4077. get: function () {
  4078. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4079. },
  4080. set: function (value) {
  4081. if (isNaN(value)) {
  4082. return;
  4083. }
  4084. this._fixedRatioMasterIsWidth = true;
  4085. this.width = value + "px";
  4086. },
  4087. enumerable: false,
  4088. configurable: true
  4089. });
  4090. Object.defineProperty(Control.prototype, "height", {
  4091. /**
  4092. * Gets or sets control height
  4093. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4094. */
  4095. get: function () {
  4096. return this._height.toString(this._host);
  4097. },
  4098. set: function (value) {
  4099. this._fixedRatioMasterIsWidth = false;
  4100. if (this._height.toString(this._host) === value) {
  4101. return;
  4102. }
  4103. if (this._height.fromString(value)) {
  4104. this._markAsDirty();
  4105. }
  4106. },
  4107. enumerable: false,
  4108. configurable: true
  4109. });
  4110. Object.defineProperty(Control.prototype, "heightInPixels", {
  4111. /**
  4112. * Gets or sets control height in pixel
  4113. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4114. */
  4115. get: function () {
  4116. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4117. },
  4118. set: function (value) {
  4119. if (isNaN(value)) {
  4120. return;
  4121. }
  4122. this._fixedRatioMasterIsWidth = false;
  4123. this.height = value + "px";
  4124. },
  4125. enumerable: false,
  4126. configurable: true
  4127. });
  4128. Object.defineProperty(Control.prototype, "fontFamily", {
  4129. /** Gets or set font family */
  4130. get: function () {
  4131. if (!this._fontSet) {
  4132. return "";
  4133. }
  4134. return this._fontFamily;
  4135. },
  4136. set: function (value) {
  4137. if (this._fontFamily === value) {
  4138. return;
  4139. }
  4140. this._fontFamily = value;
  4141. this._resetFontCache();
  4142. },
  4143. enumerable: false,
  4144. configurable: true
  4145. });
  4146. Object.defineProperty(Control.prototype, "fontStyle", {
  4147. /** Gets or sets font style */
  4148. get: function () {
  4149. return this._fontStyle;
  4150. },
  4151. set: function (value) {
  4152. if (this._fontStyle === value) {
  4153. return;
  4154. }
  4155. this._fontStyle = value;
  4156. this._resetFontCache();
  4157. },
  4158. enumerable: false,
  4159. configurable: true
  4160. });
  4161. Object.defineProperty(Control.prototype, "fontWeight", {
  4162. /** Gets or sets font weight */
  4163. get: function () {
  4164. return this._fontWeight;
  4165. },
  4166. set: function (value) {
  4167. if (this._fontWeight === value) {
  4168. return;
  4169. }
  4170. this._fontWeight = value;
  4171. this._resetFontCache();
  4172. },
  4173. enumerable: false,
  4174. configurable: true
  4175. });
  4176. Object.defineProperty(Control.prototype, "style", {
  4177. /**
  4178. * Gets or sets style
  4179. * @see https://doc.babylonjs.com/how_to/gui#styles
  4180. */
  4181. get: function () {
  4182. return this._style;
  4183. },
  4184. set: function (value) {
  4185. var _this = this;
  4186. if (this._style) {
  4187. this._style.onChangedObservable.remove(this._styleObserver);
  4188. this._styleObserver = null;
  4189. }
  4190. this._style = value;
  4191. if (this._style) {
  4192. this._styleObserver = this._style.onChangedObservable.add(function () {
  4193. _this._markAsDirty();
  4194. _this._resetFontCache();
  4195. });
  4196. }
  4197. this._markAsDirty();
  4198. this._resetFontCache();
  4199. },
  4200. enumerable: false,
  4201. configurable: true
  4202. });
  4203. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4204. /** @hidden */
  4205. get: function () {
  4206. return this._fontSize.isPercentage;
  4207. },
  4208. enumerable: false,
  4209. configurable: true
  4210. });
  4211. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4212. /** Gets or sets font size in pixels */
  4213. get: function () {
  4214. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4215. if (fontSizeToUse.isPixel) {
  4216. return fontSizeToUse.getValue(this._host);
  4217. }
  4218. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4219. },
  4220. set: function (value) {
  4221. if (isNaN(value)) {
  4222. return;
  4223. }
  4224. this.fontSize = value + "px";
  4225. },
  4226. enumerable: false,
  4227. configurable: true
  4228. });
  4229. Object.defineProperty(Control.prototype, "fontSize", {
  4230. /** Gets or sets font size */
  4231. get: function () {
  4232. return this._fontSize.toString(this._host);
  4233. },
  4234. set: function (value) {
  4235. if (this._fontSize.toString(this._host) === value) {
  4236. return;
  4237. }
  4238. if (this._fontSize.fromString(value)) {
  4239. this._markAsDirty();
  4240. this._resetFontCache();
  4241. }
  4242. },
  4243. enumerable: false,
  4244. configurable: true
  4245. });
  4246. Object.defineProperty(Control.prototype, "color", {
  4247. /** Gets or sets foreground color */
  4248. get: function () {
  4249. return this._color;
  4250. },
  4251. set: function (value) {
  4252. if (this._color === value) {
  4253. return;
  4254. }
  4255. this._color = value;
  4256. this._markAsDirty();
  4257. },
  4258. enumerable: false,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "zIndex", {
  4262. /** Gets or sets z index which is used to reorder controls on the z axis */
  4263. get: function () {
  4264. return this._zIndex;
  4265. },
  4266. set: function (value) {
  4267. if (this.zIndex === value) {
  4268. return;
  4269. }
  4270. this._zIndex = value;
  4271. if (this.parent) {
  4272. this.parent._reOrderControl(this);
  4273. }
  4274. },
  4275. enumerable: false,
  4276. configurable: true
  4277. });
  4278. Object.defineProperty(Control.prototype, "notRenderable", {
  4279. /** Gets or sets a boolean indicating if the control can be rendered */
  4280. get: function () {
  4281. return this._doNotRender;
  4282. },
  4283. set: function (value) {
  4284. if (this._doNotRender === value) {
  4285. return;
  4286. }
  4287. this._doNotRender = value;
  4288. this._markAsDirty();
  4289. },
  4290. enumerable: false,
  4291. configurable: true
  4292. });
  4293. Object.defineProperty(Control.prototype, "isVisible", {
  4294. /** Gets or sets a boolean indicating if the control is visible */
  4295. get: function () {
  4296. return this._isVisible;
  4297. },
  4298. set: function (value) {
  4299. if (this._isVisible === value) {
  4300. return;
  4301. }
  4302. this._isVisible = value;
  4303. this._markAsDirty(true);
  4304. },
  4305. enumerable: false,
  4306. configurable: true
  4307. });
  4308. Object.defineProperty(Control.prototype, "isDirty", {
  4309. /** Gets a boolean indicating that the control needs to update its rendering */
  4310. get: function () {
  4311. return this._isDirty;
  4312. },
  4313. enumerable: false,
  4314. configurable: true
  4315. });
  4316. Object.defineProperty(Control.prototype, "linkedMesh", {
  4317. /**
  4318. * Gets the current linked mesh (or null if none)
  4319. */
  4320. get: function () {
  4321. return this._linkedMesh;
  4322. },
  4323. enumerable: false,
  4324. configurable: true
  4325. });
  4326. Object.defineProperty(Control.prototype, "paddingLeft", {
  4327. /**
  4328. * Gets or sets a value indicating the padding to use on the left of the control
  4329. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4330. */
  4331. get: function () {
  4332. return this._paddingLeft.toString(this._host);
  4333. },
  4334. set: function (value) {
  4335. if (this._paddingLeft.fromString(value)) {
  4336. this._markAsDirty();
  4337. }
  4338. },
  4339. enumerable: false,
  4340. configurable: true
  4341. });
  4342. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4343. /**
  4344. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4345. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4346. */
  4347. get: function () {
  4348. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4349. },
  4350. set: function (value) {
  4351. if (isNaN(value)) {
  4352. return;
  4353. }
  4354. this.paddingLeft = value + "px";
  4355. },
  4356. enumerable: false,
  4357. configurable: true
  4358. });
  4359. Object.defineProperty(Control.prototype, "paddingRight", {
  4360. /**
  4361. * Gets or sets a value indicating the padding to use on the right of the control
  4362. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4363. */
  4364. get: function () {
  4365. return this._paddingRight.toString(this._host);
  4366. },
  4367. set: function (value) {
  4368. if (this._paddingRight.fromString(value)) {
  4369. this._markAsDirty();
  4370. }
  4371. },
  4372. enumerable: false,
  4373. configurable: true
  4374. });
  4375. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4376. /**
  4377. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4378. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4379. */
  4380. get: function () {
  4381. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4382. },
  4383. set: function (value) {
  4384. if (isNaN(value)) {
  4385. return;
  4386. }
  4387. this.paddingRight = value + "px";
  4388. },
  4389. enumerable: false,
  4390. configurable: true
  4391. });
  4392. Object.defineProperty(Control.prototype, "paddingTop", {
  4393. /**
  4394. * Gets or sets a value indicating the padding to use on the top of the control
  4395. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4396. */
  4397. get: function () {
  4398. return this._paddingTop.toString(this._host);
  4399. },
  4400. set: function (value) {
  4401. if (this._paddingTop.fromString(value)) {
  4402. this._markAsDirty();
  4403. }
  4404. },
  4405. enumerable: false,
  4406. configurable: true
  4407. });
  4408. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4409. /**
  4410. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4411. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4412. */
  4413. get: function () {
  4414. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4415. },
  4416. set: function (value) {
  4417. if (isNaN(value)) {
  4418. return;
  4419. }
  4420. this.paddingTop = value + "px";
  4421. },
  4422. enumerable: false,
  4423. configurable: true
  4424. });
  4425. Object.defineProperty(Control.prototype, "paddingBottom", {
  4426. /**
  4427. * Gets or sets a value indicating the padding to use on the bottom of the control
  4428. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4429. */
  4430. get: function () {
  4431. return this._paddingBottom.toString(this._host);
  4432. },
  4433. set: function (value) {
  4434. if (this._paddingBottom.fromString(value)) {
  4435. this._markAsDirty();
  4436. }
  4437. },
  4438. enumerable: false,
  4439. configurable: true
  4440. });
  4441. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4442. /**
  4443. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4444. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4445. */
  4446. get: function () {
  4447. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4448. },
  4449. set: function (value) {
  4450. if (isNaN(value)) {
  4451. return;
  4452. }
  4453. this.paddingBottom = value + "px";
  4454. },
  4455. enumerable: false,
  4456. configurable: true
  4457. });
  4458. Object.defineProperty(Control.prototype, "left", {
  4459. /**
  4460. * Gets or sets a value indicating the left coordinate of the control
  4461. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4462. */
  4463. get: function () {
  4464. return this._left.toString(this._host);
  4465. },
  4466. set: function (value) {
  4467. if (this._left.fromString(value)) {
  4468. this._markAsDirty();
  4469. }
  4470. },
  4471. enumerable: false,
  4472. configurable: true
  4473. });
  4474. Object.defineProperty(Control.prototype, "leftInPixels", {
  4475. /**
  4476. * Gets or sets a value indicating the left coordinate in pixels of the control
  4477. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4478. */
  4479. get: function () {
  4480. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4481. },
  4482. set: function (value) {
  4483. if (isNaN(value)) {
  4484. return;
  4485. }
  4486. this.left = value + "px";
  4487. },
  4488. enumerable: false,
  4489. configurable: true
  4490. });
  4491. Object.defineProperty(Control.prototype, "top", {
  4492. /**
  4493. * Gets or sets a value indicating the top coordinate of the control
  4494. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4495. */
  4496. get: function () {
  4497. return this._top.toString(this._host);
  4498. },
  4499. set: function (value) {
  4500. if (this._top.fromString(value)) {
  4501. this._markAsDirty();
  4502. }
  4503. },
  4504. enumerable: false,
  4505. configurable: true
  4506. });
  4507. Object.defineProperty(Control.prototype, "topInPixels", {
  4508. /**
  4509. * Gets or sets a value indicating the top coordinate in pixels of the control
  4510. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4511. */
  4512. get: function () {
  4513. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4514. },
  4515. set: function (value) {
  4516. if (isNaN(value)) {
  4517. return;
  4518. }
  4519. this.top = value + "px";
  4520. },
  4521. enumerable: false,
  4522. configurable: true
  4523. });
  4524. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4525. /**
  4526. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4527. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4528. */
  4529. get: function () {
  4530. return this._linkOffsetX.toString(this._host);
  4531. },
  4532. set: function (value) {
  4533. if (this._linkOffsetX.fromString(value)) {
  4534. this._markAsDirty();
  4535. }
  4536. },
  4537. enumerable: false,
  4538. configurable: true
  4539. });
  4540. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4541. /**
  4542. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4543. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4544. */
  4545. get: function () {
  4546. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4547. },
  4548. set: function (value) {
  4549. if (isNaN(value)) {
  4550. return;
  4551. }
  4552. this.linkOffsetX = value + "px";
  4553. },
  4554. enumerable: false,
  4555. configurable: true
  4556. });
  4557. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4558. /**
  4559. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4560. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4561. */
  4562. get: function () {
  4563. return this._linkOffsetY.toString(this._host);
  4564. },
  4565. set: function (value) {
  4566. if (this._linkOffsetY.fromString(value)) {
  4567. this._markAsDirty();
  4568. }
  4569. },
  4570. enumerable: false,
  4571. configurable: true
  4572. });
  4573. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4574. /**
  4575. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4576. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4577. */
  4578. get: function () {
  4579. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4580. },
  4581. set: function (value) {
  4582. if (isNaN(value)) {
  4583. return;
  4584. }
  4585. this.linkOffsetY = value + "px";
  4586. },
  4587. enumerable: false,
  4588. configurable: true
  4589. });
  4590. Object.defineProperty(Control.prototype, "centerX", {
  4591. /** Gets the center coordinate on X axis */
  4592. get: function () {
  4593. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4594. },
  4595. enumerable: false,
  4596. configurable: true
  4597. });
  4598. Object.defineProperty(Control.prototype, "centerY", {
  4599. /** Gets the center coordinate on Y axis */
  4600. get: function () {
  4601. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4602. },
  4603. enumerable: false,
  4604. configurable: true
  4605. });
  4606. Object.defineProperty(Control.prototype, "isEnabled", {
  4607. /** Gets or sets if control is Enabled*/
  4608. get: function () {
  4609. return this._isEnabled;
  4610. },
  4611. set: function (value) {
  4612. if (this._isEnabled === value) {
  4613. return;
  4614. }
  4615. this._isEnabled = value;
  4616. this._markAsDirty();
  4617. },
  4618. enumerable: false,
  4619. configurable: true
  4620. });
  4621. Object.defineProperty(Control.prototype, "disabledColor", {
  4622. /** Gets or sets background color of control if it's disabled*/
  4623. get: function () {
  4624. return this._disabledColor;
  4625. },
  4626. set: function (value) {
  4627. if (this._disabledColor === value) {
  4628. return;
  4629. }
  4630. this._disabledColor = value;
  4631. this._markAsDirty();
  4632. },
  4633. enumerable: false,
  4634. configurable: true
  4635. });
  4636. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4637. /** Gets or sets front color of control if it's disabled*/
  4638. get: function () {
  4639. return this._disabledColorItem;
  4640. },
  4641. set: function (value) {
  4642. if (this._disabledColorItem === value) {
  4643. return;
  4644. }
  4645. this._disabledColorItem = value;
  4646. this._markAsDirty();
  4647. },
  4648. enumerable: false,
  4649. configurable: true
  4650. });
  4651. /** @hidden */
  4652. Control.prototype._getTypeName = function () {
  4653. return "Control";
  4654. };
  4655. /**
  4656. * Gets the first ascendant in the hierarchy of the given type
  4657. * @param className defines the required type
  4658. * @returns the ascendant or null if not found
  4659. */
  4660. Control.prototype.getAscendantOfClass = function (className) {
  4661. if (!this.parent) {
  4662. return null;
  4663. }
  4664. if (this.parent.getClassName() === className) {
  4665. return this.parent;
  4666. }
  4667. return this.parent.getAscendantOfClass(className);
  4668. };
  4669. /** @hidden */
  4670. Control.prototype._resetFontCache = function () {
  4671. this._fontSet = true;
  4672. this._markAsDirty();
  4673. };
  4674. /**
  4675. * Determines if a container is an ascendant of the current control
  4676. * @param container defines the container to look for
  4677. * @returns true if the container is one of the ascendant of the control
  4678. */
  4679. Control.prototype.isAscendant = function (container) {
  4680. if (!this.parent) {
  4681. return false;
  4682. }
  4683. if (this.parent === container) {
  4684. return true;
  4685. }
  4686. return this.parent.isAscendant(container);
  4687. };
  4688. /**
  4689. * Gets coordinates in local control space
  4690. * @param globalCoordinates defines the coordinates to transform
  4691. * @returns the new coordinates in local space
  4692. */
  4693. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4694. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4695. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4696. return result;
  4697. };
  4698. /**
  4699. * Gets coordinates in local control space
  4700. * @param globalCoordinates defines the coordinates to transform
  4701. * @param result defines the target vector2 where to store the result
  4702. * @returns the current control
  4703. */
  4704. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4705. result.x = globalCoordinates.x - this._currentMeasure.left;
  4706. result.y = globalCoordinates.y - this._currentMeasure.top;
  4707. return this;
  4708. };
  4709. /**
  4710. * Gets coordinates in parent local control space
  4711. * @param globalCoordinates defines the coordinates to transform
  4712. * @returns the new coordinates in parent local space
  4713. */
  4714. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4715. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4716. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4717. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4718. return result;
  4719. };
  4720. /**
  4721. * Move the current control to a vector3 position projected onto the screen.
  4722. * @param position defines the target position
  4723. * @param scene defines the hosting scene
  4724. */
  4725. Control.prototype.moveToVector3 = function (position, scene) {
  4726. if (!this._host || this.parent !== this._host._rootContainer) {
  4727. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4728. return;
  4729. }
  4730. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4731. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4732. var globalViewport = this._host._getGlobalViewport(scene);
  4733. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4734. this._moveToProjectedPosition(projectedPosition);
  4735. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4736. this.notRenderable = true;
  4737. return;
  4738. }
  4739. this.notRenderable = false;
  4740. };
  4741. /**
  4742. * Will store all controls that have this control as ascendant in a given array
  4743. * @param results defines the array where to store the descendants
  4744. * @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
  4745. * @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
  4746. */
  4747. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4748. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4749. // Do nothing by default
  4750. };
  4751. /**
  4752. * Will return all controls that have this control as ascendant
  4753. * @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
  4754. * @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
  4755. * @return all child controls
  4756. */
  4757. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4758. var results = new Array();
  4759. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4760. return results;
  4761. };
  4762. /**
  4763. * Link current control with a target mesh
  4764. * @param mesh defines the mesh to link with
  4765. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4766. */
  4767. Control.prototype.linkWithMesh = function (mesh) {
  4768. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4769. if (mesh) {
  4770. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4771. }
  4772. return;
  4773. }
  4774. var index = this._host._linkedControls.indexOf(this);
  4775. if (index !== -1) {
  4776. this._linkedMesh = mesh;
  4777. if (!mesh) {
  4778. this._host._linkedControls.splice(index, 1);
  4779. }
  4780. return;
  4781. }
  4782. else if (!mesh) {
  4783. return;
  4784. }
  4785. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4786. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4787. this._linkedMesh = mesh;
  4788. this._host._linkedControls.push(this);
  4789. };
  4790. /** @hidden */
  4791. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4792. var oldLeft = this._left.getValue(this._host);
  4793. var oldTop = this._top.getValue(this._host);
  4794. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4795. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4796. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4797. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4798. newLeft = oldLeft;
  4799. }
  4800. if (Math.abs(newTop - oldTop) < 0.5) {
  4801. newTop = oldTop;
  4802. }
  4803. }
  4804. this.left = newLeft + "px";
  4805. this.top = newTop + "px";
  4806. this._left.ignoreAdaptiveScaling = true;
  4807. this._top.ignoreAdaptiveScaling = true;
  4808. this._markAsDirty();
  4809. };
  4810. /** @hidden */
  4811. Control.prototype._offsetLeft = function (offset) {
  4812. this._isDirty = true;
  4813. this._currentMeasure.left += offset;
  4814. };
  4815. /** @hidden */
  4816. Control.prototype._offsetTop = function (offset) {
  4817. this._isDirty = true;
  4818. this._currentMeasure.top += offset;
  4819. };
  4820. /** @hidden */
  4821. Control.prototype._markMatrixAsDirty = function () {
  4822. this._isMatrixDirty = true;
  4823. this._flagDescendantsAsMatrixDirty();
  4824. };
  4825. /** @hidden */
  4826. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4827. // No child
  4828. };
  4829. /** @hidden */
  4830. Control.prototype._intersectsRect = function (rect) {
  4831. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4832. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4833. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4834. return false;
  4835. }
  4836. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4837. return false;
  4838. }
  4839. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4840. return false;
  4841. }
  4842. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4843. return false;
  4844. }
  4845. return true;
  4846. };
  4847. /** @hidden */
  4848. Control.prototype.invalidateRect = function () {
  4849. this._transform();
  4850. if (this.host && this.host.useInvalidateRectOptimization) {
  4851. // Rotate by transform to get the measure transformed to global space
  4852. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4853. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4854. // the previous measure is used to properly clear a control that is scaled down
  4855. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4856. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4857. // Expand rect based on shadows
  4858. var shadowOffsetX = this.shadowOffsetX;
  4859. var shadowOffsetY = this.shadowOffsetY;
  4860. var shadowBlur = this.shadowBlur;
  4861. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4862. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4863. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4864. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4865. 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));
  4866. }
  4867. else {
  4868. 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));
  4869. }
  4870. }
  4871. };
  4872. /** @hidden */
  4873. Control.prototype._markAsDirty = function (force) {
  4874. if (force === void 0) { force = false; }
  4875. if (!this._isVisible && !force) {
  4876. return;
  4877. }
  4878. this._isDirty = true;
  4879. // Redraw only this rectangle
  4880. if (this._host) {
  4881. this._host.markAsDirty();
  4882. }
  4883. };
  4884. /** @hidden */
  4885. Control.prototype._markAllAsDirty = function () {
  4886. this._markAsDirty();
  4887. if (this._font) {
  4888. this._prepareFont();
  4889. }
  4890. };
  4891. /** @hidden */
  4892. Control.prototype._link = function (host) {
  4893. this._host = host;
  4894. if (this._host) {
  4895. this.uniqueId = this._host.getScene().getUniqueId();
  4896. }
  4897. };
  4898. /** @hidden */
  4899. Control.prototype._transform = function (context) {
  4900. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4901. return;
  4902. }
  4903. // postTranslate
  4904. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4905. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4906. if (context) {
  4907. context.translate(offsetX, offsetY);
  4908. // rotate
  4909. context.rotate(this._rotation);
  4910. // scale
  4911. context.scale(this._scaleX, this._scaleY);
  4912. // preTranslate
  4913. context.translate(-offsetX, -offsetY);
  4914. }
  4915. // Need to update matrices?
  4916. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4917. this._cachedOffsetX = offsetX;
  4918. this._cachedOffsetY = offsetY;
  4919. this._isMatrixDirty = false;
  4920. this._flagDescendantsAsMatrixDirty();
  4921. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4922. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4923. }
  4924. };
  4925. /** @hidden */
  4926. Control.prototype._renderHighlight = function (context) {
  4927. if (!this.isHighlighted) {
  4928. return;
  4929. }
  4930. context.save();
  4931. context.strokeStyle = "#4affff";
  4932. context.lineWidth = 2;
  4933. this._renderHighlightSpecific(context);
  4934. context.restore();
  4935. };
  4936. /** @hidden */
  4937. Control.prototype._renderHighlightSpecific = function (context) {
  4938. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4939. };
  4940. /** @hidden */
  4941. Control.prototype._applyStates = function (context) {
  4942. if (this._isFontSizeInPercentage) {
  4943. this._fontSet = true;
  4944. }
  4945. if (this._fontSet) {
  4946. this._prepareFont();
  4947. this._fontSet = false;
  4948. }
  4949. if (this._font) {
  4950. context.font = this._font;
  4951. }
  4952. if (this._color) {
  4953. context.fillStyle = this._color;
  4954. }
  4955. if (Control.AllowAlphaInheritance) {
  4956. context.globalAlpha *= this._alpha;
  4957. }
  4958. else if (this._alphaSet) {
  4959. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4960. }
  4961. };
  4962. /** @hidden */
  4963. Control.prototype._layout = function (parentMeasure, context) {
  4964. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4965. return false;
  4966. }
  4967. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4968. this.host._numLayoutCalls++;
  4969. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4970. context.save();
  4971. this._applyStates(context);
  4972. var rebuildCount = 0;
  4973. do {
  4974. this._rebuildLayout = false;
  4975. this._processMeasures(parentMeasure, context);
  4976. rebuildCount++;
  4977. } while (this._rebuildLayout && rebuildCount < 3);
  4978. if (rebuildCount >= 3) {
  4979. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4980. }
  4981. context.restore();
  4982. this.invalidateRect();
  4983. this._evaluateClippingState(parentMeasure);
  4984. }
  4985. this._wasDirty = this._isDirty;
  4986. this._isDirty = false;
  4987. return true;
  4988. };
  4989. /** @hidden */
  4990. Control.prototype._processMeasures = function (parentMeasure, context) {
  4991. this._currentMeasure.copyFrom(parentMeasure);
  4992. // Let children take some pre-measurement actions
  4993. this._preMeasure(parentMeasure, context);
  4994. this._measure();
  4995. this._computeAlignment(parentMeasure, context);
  4996. // Convert to int values
  4997. this._currentMeasure.left = this._currentMeasure.left | 0;
  4998. this._currentMeasure.top = this._currentMeasure.top | 0;
  4999. this._currentMeasure.width = this._currentMeasure.width | 0;
  5000. this._currentMeasure.height = this._currentMeasure.height | 0;
  5001. // Let children add more features
  5002. this._additionalProcessing(parentMeasure, context);
  5003. this._cachedParentMeasure.copyFrom(parentMeasure);
  5004. if (this.onDirtyObservable.hasObservers()) {
  5005. this.onDirtyObservable.notifyObservers(this);
  5006. }
  5007. };
  5008. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5009. if (this.parent && this.parent.clipChildren) {
  5010. // Early clip
  5011. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5012. this._isClipped = true;
  5013. return;
  5014. }
  5015. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5016. this._isClipped = true;
  5017. return;
  5018. }
  5019. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5020. this._isClipped = true;
  5021. return;
  5022. }
  5023. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5024. this._isClipped = true;
  5025. return;
  5026. }
  5027. }
  5028. this._isClipped = false;
  5029. };
  5030. /** @hidden */
  5031. Control.prototype._measure = function () {
  5032. // Width / Height
  5033. if (this._width.isPixel) {
  5034. this._currentMeasure.width = this._width.getValue(this._host);
  5035. }
  5036. else {
  5037. this._currentMeasure.width *= this._width.getValue(this._host);
  5038. }
  5039. if (this._height.isPixel) {
  5040. this._currentMeasure.height = this._height.getValue(this._host);
  5041. }
  5042. else {
  5043. this._currentMeasure.height *= this._height.getValue(this._host);
  5044. }
  5045. if (this.fixedRatio !== 0) {
  5046. if (this._fixedRatioMasterIsWidth) {
  5047. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5048. }
  5049. else {
  5050. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5051. }
  5052. }
  5053. };
  5054. /** @hidden */
  5055. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5056. var width = this._currentMeasure.width;
  5057. var height = this._currentMeasure.height;
  5058. var parentWidth = parentMeasure.width;
  5059. var parentHeight = parentMeasure.height;
  5060. // Left / top
  5061. var x = 0;
  5062. var y = 0;
  5063. switch (this.horizontalAlignment) {
  5064. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5065. x = 0;
  5066. break;
  5067. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5068. x = parentWidth - width;
  5069. break;
  5070. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5071. x = (parentWidth - width) / 2;
  5072. break;
  5073. }
  5074. switch (this.verticalAlignment) {
  5075. case Control.VERTICAL_ALIGNMENT_TOP:
  5076. y = 0;
  5077. break;
  5078. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5079. y = parentHeight - height;
  5080. break;
  5081. case Control.VERTICAL_ALIGNMENT_CENTER:
  5082. y = (parentHeight - height) / 2;
  5083. break;
  5084. }
  5085. if (this._paddingLeft.isPixel) {
  5086. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5087. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5088. }
  5089. else {
  5090. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5091. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5092. }
  5093. if (this._paddingRight.isPixel) {
  5094. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5095. }
  5096. else {
  5097. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5098. }
  5099. if (this._paddingTop.isPixel) {
  5100. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5101. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5102. }
  5103. else {
  5104. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5105. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5106. }
  5107. if (this._paddingBottom.isPixel) {
  5108. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5109. }
  5110. else {
  5111. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5112. }
  5113. if (this._left.isPixel) {
  5114. this._currentMeasure.left += this._left.getValue(this._host);
  5115. }
  5116. else {
  5117. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5118. }
  5119. if (this._top.isPixel) {
  5120. this._currentMeasure.top += this._top.getValue(this._host);
  5121. }
  5122. else {
  5123. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5124. }
  5125. this._currentMeasure.left += x;
  5126. this._currentMeasure.top += y;
  5127. };
  5128. /** @hidden */
  5129. Control.prototype._preMeasure = function (parentMeasure, context) {
  5130. // Do nothing
  5131. };
  5132. /** @hidden */
  5133. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5134. // Do nothing
  5135. };
  5136. /** @hidden */
  5137. Control.prototype._clipForChildren = function (context) {
  5138. // DO nothing
  5139. };
  5140. Control.prototype._clip = function (context, invalidatedRectangle) {
  5141. context.beginPath();
  5142. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5143. if (invalidatedRectangle) {
  5144. // Rotate the invalidated rect into the control's space
  5145. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5146. // Get the intersection of the rect in context space and the current context
  5147. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5148. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5149. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5150. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5151. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5152. Control._ClipMeasure.copyFrom(intersection);
  5153. }
  5154. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5155. var shadowOffsetX = this.shadowOffsetX;
  5156. var shadowOffsetY = this.shadowOffsetY;
  5157. var shadowBlur = this.shadowBlur;
  5158. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5159. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5160. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5161. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5162. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5163. }
  5164. else {
  5165. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5166. }
  5167. context.clip();
  5168. };
  5169. /** @hidden */
  5170. Control.prototype._render = function (context, invalidatedRectangle) {
  5171. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5172. this._isDirty = false;
  5173. return false;
  5174. }
  5175. this.host._numRenderCalls++;
  5176. context.save();
  5177. this._applyStates(context);
  5178. // Transform
  5179. this._transform(context);
  5180. // Clip
  5181. if (this.clipContent) {
  5182. this._clip(context, invalidatedRectangle);
  5183. }
  5184. if (this.onBeforeDrawObservable.hasObservers()) {
  5185. this.onBeforeDrawObservable.notifyObservers(this);
  5186. }
  5187. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5188. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5189. }
  5190. else {
  5191. this._draw(context, invalidatedRectangle);
  5192. }
  5193. if (this.useBitmapCache && this._wasDirty) {
  5194. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5195. }
  5196. this._renderHighlight(context);
  5197. if (this.onAfterDrawObservable.hasObservers()) {
  5198. this.onAfterDrawObservable.notifyObservers(this);
  5199. }
  5200. context.restore();
  5201. return true;
  5202. };
  5203. /** @hidden */
  5204. Control.prototype._draw = function (context, invalidatedRectangle) {
  5205. // Do nothing
  5206. };
  5207. /**
  5208. * Tests if a given coordinates belong to the current control
  5209. * @param x defines x coordinate to test
  5210. * @param y defines y coordinate to test
  5211. * @returns true if the coordinates are inside the control
  5212. */
  5213. Control.prototype.contains = function (x, y) {
  5214. // Invert transform
  5215. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5216. x = this._transformedPosition.x;
  5217. y = this._transformedPosition.y;
  5218. // Check
  5219. if (x < this._currentMeasure.left) {
  5220. return false;
  5221. }
  5222. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5223. return false;
  5224. }
  5225. if (y < this._currentMeasure.top) {
  5226. return false;
  5227. }
  5228. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5229. return false;
  5230. }
  5231. if (this.isPointerBlocker) {
  5232. this._host._shouldBlockPointer = true;
  5233. }
  5234. return true;
  5235. };
  5236. /** @hidden */
  5237. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5238. if (!this._isEnabled) {
  5239. return false;
  5240. }
  5241. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5242. return false;
  5243. }
  5244. if (!this.contains(x, y)) {
  5245. return false;
  5246. }
  5247. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5248. return true;
  5249. };
  5250. /** @hidden */
  5251. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5252. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5253. if (canNotify && this.parent != null) {
  5254. this.parent._onPointerMove(target, coordinates, pointerId);
  5255. }
  5256. };
  5257. /** @hidden */
  5258. Control.prototype._onPointerEnter = function (target) {
  5259. if (!this._isEnabled) {
  5260. return false;
  5261. }
  5262. if (this._enterCount > 0) {
  5263. return false;
  5264. }
  5265. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5266. this._enterCount = 0;
  5267. }
  5268. this._enterCount++;
  5269. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5270. if (canNotify && this.parent != null) {
  5271. this.parent._onPointerEnter(target);
  5272. }
  5273. return true;
  5274. };
  5275. /** @hidden */
  5276. Control.prototype._onPointerOut = function (target, force) {
  5277. if (force === void 0) { force = false; }
  5278. if (!force && (!this._isEnabled || target === this)) {
  5279. return;
  5280. }
  5281. this._enterCount = 0;
  5282. var canNotify = true;
  5283. if (!target.isAscendant(this)) {
  5284. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5285. }
  5286. if (canNotify && this.parent != null) {
  5287. this.parent._onPointerOut(target, force);
  5288. }
  5289. };
  5290. /** @hidden */
  5291. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5292. // Prevent pointerout to lose control context.
  5293. // Event redundancy is checked inside the function.
  5294. this._onPointerEnter(this);
  5295. if (this._downCount !== 0) {
  5296. return false;
  5297. }
  5298. this._downCount++;
  5299. this._downPointerIds[pointerId] = true;
  5300. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5301. if (canNotify && this.parent != null) {
  5302. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5303. }
  5304. return true;
  5305. };
  5306. /** @hidden */
  5307. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5308. if (!this._isEnabled) {
  5309. return;
  5310. }
  5311. this._downCount = 0;
  5312. delete this._downPointerIds[pointerId];
  5313. var canNotifyClick = notifyClick;
  5314. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5315. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5316. }
  5317. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5318. if (canNotify && this.parent != null) {
  5319. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5320. }
  5321. };
  5322. /** @hidden */
  5323. Control.prototype._forcePointerUp = function (pointerId) {
  5324. if (pointerId === void 0) { pointerId = null; }
  5325. if (pointerId !== null) {
  5326. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5327. }
  5328. else {
  5329. for (var key in this._downPointerIds) {
  5330. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5331. }
  5332. }
  5333. };
  5334. /** @hidden */
  5335. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5336. if (!this._isEnabled) {
  5337. return;
  5338. }
  5339. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5340. if (canNotify && this.parent != null) {
  5341. this.parent._onWheelScroll(deltaX, deltaY);
  5342. }
  5343. };
  5344. /** @hidden */
  5345. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5346. if (!this._isEnabled) {
  5347. return false;
  5348. }
  5349. this._dummyVector2.copyFromFloats(x, y);
  5350. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5351. this._onPointerMove(this, this._dummyVector2, pointerId);
  5352. var previousControlOver = this._host._lastControlOver[pointerId];
  5353. if (previousControlOver && previousControlOver !== this) {
  5354. previousControlOver._onPointerOut(this);
  5355. }
  5356. if (previousControlOver !== this) {
  5357. this._onPointerEnter(this);
  5358. }
  5359. this._host._lastControlOver[pointerId] = this;
  5360. return true;
  5361. }
  5362. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5363. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5364. this._host._registerLastControlDown(this, pointerId);
  5365. this._host._lastPickedControl = this;
  5366. return true;
  5367. }
  5368. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5369. if (this._host._lastControlDown[pointerId]) {
  5370. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5371. }
  5372. delete this._host._lastControlDown[pointerId];
  5373. return true;
  5374. }
  5375. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5376. if (this._host._lastControlOver[pointerId]) {
  5377. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5378. return true;
  5379. }
  5380. }
  5381. return false;
  5382. };
  5383. Control.prototype._prepareFont = function () {
  5384. if (!this._font && !this._fontSet) {
  5385. return;
  5386. }
  5387. if (this._style) {
  5388. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5389. }
  5390. else {
  5391. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5392. }
  5393. this._fontOffset = Control._GetFontOffset(this._font);
  5394. };
  5395. /** Releases associated resources */
  5396. Control.prototype.dispose = function () {
  5397. this.onDirtyObservable.clear();
  5398. this.onBeforeDrawObservable.clear();
  5399. this.onAfterDrawObservable.clear();
  5400. this.onPointerDownObservable.clear();
  5401. this.onPointerEnterObservable.clear();
  5402. this.onPointerMoveObservable.clear();
  5403. this.onPointerOutObservable.clear();
  5404. this.onPointerUpObservable.clear();
  5405. this.onPointerClickObservable.clear();
  5406. this.onWheelObservable.clear();
  5407. if (this._styleObserver && this._style) {
  5408. this._style.onChangedObservable.remove(this._styleObserver);
  5409. this._styleObserver = null;
  5410. }
  5411. if (this.parent) {
  5412. this.parent.removeControl(this);
  5413. this.parent = null;
  5414. }
  5415. if (this._host) {
  5416. var index = this._host._linkedControls.indexOf(this);
  5417. if (index > -1) {
  5418. this.linkWithMesh(null);
  5419. }
  5420. }
  5421. // Callback
  5422. this.onDisposeObservable.notifyObservers(this);
  5423. this.onDisposeObservable.clear();
  5424. };
  5425. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5426. /** HORIZONTAL_ALIGNMENT_LEFT */
  5427. get: function () {
  5428. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5429. },
  5430. enumerable: false,
  5431. configurable: true
  5432. });
  5433. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5434. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5435. get: function () {
  5436. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5437. },
  5438. enumerable: false,
  5439. configurable: true
  5440. });
  5441. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5442. /** HORIZONTAL_ALIGNMENT_CENTER */
  5443. get: function () {
  5444. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5445. },
  5446. enumerable: false,
  5447. configurable: true
  5448. });
  5449. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5450. /** VERTICAL_ALIGNMENT_TOP */
  5451. get: function () {
  5452. return Control._VERTICAL_ALIGNMENT_TOP;
  5453. },
  5454. enumerable: false,
  5455. configurable: true
  5456. });
  5457. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5458. /** VERTICAL_ALIGNMENT_BOTTOM */
  5459. get: function () {
  5460. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5461. },
  5462. enumerable: false,
  5463. configurable: true
  5464. });
  5465. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5466. /** VERTICAL_ALIGNMENT_CENTER */
  5467. get: function () {
  5468. return Control._VERTICAL_ALIGNMENT_CENTER;
  5469. },
  5470. enumerable: false,
  5471. configurable: true
  5472. });
  5473. /** @hidden */
  5474. Control._GetFontOffset = function (font) {
  5475. if (Control._FontHeightSizes[font]) {
  5476. return Control._FontHeightSizes[font];
  5477. }
  5478. var text = document.createElement("span");
  5479. text.innerHTML = "Hg";
  5480. text.style.font = font;
  5481. var block = document.createElement("div");
  5482. block.style.display = "inline-block";
  5483. block.style.width = "1px";
  5484. block.style.height = "0px";
  5485. block.style.verticalAlign = "bottom";
  5486. var div = document.createElement("div");
  5487. div.appendChild(text);
  5488. div.appendChild(block);
  5489. document.body.appendChild(div);
  5490. var fontAscent = 0;
  5491. var fontHeight = 0;
  5492. try {
  5493. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5494. block.style.verticalAlign = "baseline";
  5495. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5496. }
  5497. finally {
  5498. document.body.removeChild(div);
  5499. }
  5500. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5501. Control._FontHeightSizes[font] = result;
  5502. return result;
  5503. };
  5504. /** @hidden */
  5505. Control.drawEllipse = function (x, y, width, height, context) {
  5506. context.translate(x, y);
  5507. context.scale(width, height);
  5508. context.beginPath();
  5509. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5510. context.closePath();
  5511. context.scale(1 / width, 1 / height);
  5512. context.translate(-x, -y);
  5513. };
  5514. /**
  5515. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5516. */
  5517. Control.AllowAlphaInheritance = false;
  5518. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5519. // Statics
  5520. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5521. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5522. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5523. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5524. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5525. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5526. Control._FontHeightSizes = {};
  5527. /**
  5528. * Creates a stack panel that can be used to render headers
  5529. * @param control defines the control to associate with the header
  5530. * @param text defines the text of the header
  5531. * @param size defines the size of the header
  5532. * @param options defines options used to configure the header
  5533. * @returns a new StackPanel
  5534. * @ignore
  5535. * @hidden
  5536. */
  5537. Control.AddHeader = function () { };
  5538. return Control;
  5539. }());
  5540. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5541. /***/ }),
  5542. /***/ "./2D/controls/displayGrid.ts":
  5543. /*!************************************!*\
  5544. !*** ./2D/controls/displayGrid.ts ***!
  5545. \************************************/
  5546. /*! exports provided: DisplayGrid */
  5547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5548. "use strict";
  5549. __webpack_require__.r(__webpack_exports__);
  5550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5551. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5552. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5553. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5554. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5555. /** Class used to render a grid */
  5556. var DisplayGrid = /** @class */ (function (_super) {
  5557. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5558. /**
  5559. * Creates a new GridDisplayRectangle
  5560. * @param name defines the control name
  5561. */
  5562. function DisplayGrid(name) {
  5563. var _this = _super.call(this, name) || this;
  5564. _this.name = name;
  5565. _this._cellWidth = 20;
  5566. _this._cellHeight = 20;
  5567. _this._minorLineTickness = 1;
  5568. _this._minorLineColor = "DarkGray";
  5569. _this._majorLineTickness = 2;
  5570. _this._majorLineColor = "White";
  5571. _this._majorLineFrequency = 5;
  5572. _this._background = "Black";
  5573. _this._displayMajorLines = true;
  5574. _this._displayMinorLines = true;
  5575. return _this;
  5576. }
  5577. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5578. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5579. get: function () {
  5580. return this._displayMinorLines;
  5581. },
  5582. set: function (value) {
  5583. if (this._displayMinorLines === value) {
  5584. return;
  5585. }
  5586. this._displayMinorLines = value;
  5587. this._markAsDirty();
  5588. },
  5589. enumerable: false,
  5590. configurable: true
  5591. });
  5592. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5593. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5594. get: function () {
  5595. return this._displayMajorLines;
  5596. },
  5597. set: function (value) {
  5598. if (this._displayMajorLines === value) {
  5599. return;
  5600. }
  5601. this._displayMajorLines = value;
  5602. this._markAsDirty();
  5603. },
  5604. enumerable: false,
  5605. configurable: true
  5606. });
  5607. Object.defineProperty(DisplayGrid.prototype, "background", {
  5608. /** Gets or sets background color (Black by default) */
  5609. get: function () {
  5610. return this._background;
  5611. },
  5612. set: function (value) {
  5613. if (this._background === value) {
  5614. return;
  5615. }
  5616. this._background = value;
  5617. this._markAsDirty();
  5618. },
  5619. enumerable: false,
  5620. configurable: true
  5621. });
  5622. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5623. /** Gets or sets the width of each cell (20 by default) */
  5624. get: function () {
  5625. return this._cellWidth;
  5626. },
  5627. set: function (value) {
  5628. this._cellWidth = value;
  5629. this._markAsDirty();
  5630. },
  5631. enumerable: false,
  5632. configurable: true
  5633. });
  5634. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5635. /** Gets or sets the height of each cell (20 by default) */
  5636. get: function () {
  5637. return this._cellHeight;
  5638. },
  5639. set: function (value) {
  5640. this._cellHeight = value;
  5641. this._markAsDirty();
  5642. },
  5643. enumerable: false,
  5644. configurable: true
  5645. });
  5646. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5647. /** Gets or sets the tickness of minor lines (1 by default) */
  5648. get: function () {
  5649. return this._minorLineTickness;
  5650. },
  5651. set: function (value) {
  5652. this._minorLineTickness = value;
  5653. this._markAsDirty();
  5654. },
  5655. enumerable: false,
  5656. configurable: true
  5657. });
  5658. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5659. /** Gets or sets the color of minor lines (DarkGray by default) */
  5660. get: function () {
  5661. return this._minorLineColor;
  5662. },
  5663. set: function (value) {
  5664. this._minorLineColor = value;
  5665. this._markAsDirty();
  5666. },
  5667. enumerable: false,
  5668. configurable: true
  5669. });
  5670. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5671. /** Gets or sets the tickness of major lines (2 by default) */
  5672. get: function () {
  5673. return this._majorLineTickness;
  5674. },
  5675. set: function (value) {
  5676. this._majorLineTickness = value;
  5677. this._markAsDirty();
  5678. },
  5679. enumerable: false,
  5680. configurable: true
  5681. });
  5682. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5683. /** Gets or sets the color of major lines (White by default) */
  5684. get: function () {
  5685. return this._majorLineColor;
  5686. },
  5687. set: function (value) {
  5688. this._majorLineColor = value;
  5689. this._markAsDirty();
  5690. },
  5691. enumerable: false,
  5692. configurable: true
  5693. });
  5694. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5695. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5696. get: function () {
  5697. return this._majorLineFrequency;
  5698. },
  5699. set: function (value) {
  5700. this._majorLineFrequency = value;
  5701. this._markAsDirty();
  5702. },
  5703. enumerable: false,
  5704. configurable: true
  5705. });
  5706. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5707. context.save();
  5708. this._applyStates(context);
  5709. if (this._isEnabled) {
  5710. if (this._background) {
  5711. context.fillStyle = this._background;
  5712. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5713. }
  5714. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5715. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5716. // Minor lines
  5717. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5718. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5719. if (this._displayMinorLines) {
  5720. context.strokeStyle = this._minorLineColor;
  5721. context.lineWidth = this._minorLineTickness;
  5722. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5723. var cellX = left + x * this.cellWidth;
  5724. context.beginPath();
  5725. context.moveTo(cellX, this._currentMeasure.top);
  5726. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5727. context.stroke();
  5728. }
  5729. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5730. var cellY = top_1 + y * this.cellHeight;
  5731. context.beginPath();
  5732. context.moveTo(this._currentMeasure.left, cellY);
  5733. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5734. context.stroke();
  5735. }
  5736. }
  5737. // Major lines
  5738. if (this._displayMajorLines) {
  5739. context.strokeStyle = this._majorLineColor;
  5740. context.lineWidth = this._majorLineTickness;
  5741. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5742. var cellX = left + x * this.cellWidth;
  5743. context.beginPath();
  5744. context.moveTo(cellX, this._currentMeasure.top);
  5745. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5746. context.stroke();
  5747. }
  5748. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5749. var cellY = top_1 + y * this.cellHeight;
  5750. context.moveTo(this._currentMeasure.left, cellY);
  5751. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5752. context.closePath();
  5753. context.stroke();
  5754. }
  5755. }
  5756. }
  5757. context.restore();
  5758. };
  5759. DisplayGrid.prototype._getTypeName = function () {
  5760. return "DisplayGrid";
  5761. };
  5762. return DisplayGrid;
  5763. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5764. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5765. /***/ }),
  5766. /***/ "./2D/controls/ellipse.ts":
  5767. /*!********************************!*\
  5768. !*** ./2D/controls/ellipse.ts ***!
  5769. \********************************/
  5770. /*! exports provided: Ellipse */
  5771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5772. "use strict";
  5773. __webpack_require__.r(__webpack_exports__);
  5774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5775. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5776. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5777. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5778. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5779. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5780. /** Class used to create 2D ellipse containers */
  5781. var Ellipse = /** @class */ (function (_super) {
  5782. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5783. /**
  5784. * Creates a new Ellipse
  5785. * @param name defines the control name
  5786. */
  5787. function Ellipse(name) {
  5788. var _this = _super.call(this, name) || this;
  5789. _this.name = name;
  5790. _this._thickness = 1;
  5791. return _this;
  5792. }
  5793. Object.defineProperty(Ellipse.prototype, "thickness", {
  5794. /** Gets or sets border thickness */
  5795. get: function () {
  5796. return this._thickness;
  5797. },
  5798. set: function (value) {
  5799. if (this._thickness === value) {
  5800. return;
  5801. }
  5802. this._thickness = value;
  5803. this._markAsDirty();
  5804. },
  5805. enumerable: false,
  5806. configurable: true
  5807. });
  5808. Ellipse.prototype._getTypeName = function () {
  5809. return "Ellipse";
  5810. };
  5811. Ellipse.prototype._localDraw = function (context) {
  5812. context.save();
  5813. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5814. context.shadowColor = this.shadowColor;
  5815. context.shadowBlur = this.shadowBlur;
  5816. context.shadowOffsetX = this.shadowOffsetX;
  5817. context.shadowOffsetY = this.shadowOffsetY;
  5818. }
  5819. _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);
  5820. if (this._background) {
  5821. context.fillStyle = this._background;
  5822. context.fill();
  5823. }
  5824. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5825. context.shadowBlur = 0;
  5826. context.shadowOffsetX = 0;
  5827. context.shadowOffsetY = 0;
  5828. }
  5829. if (this._thickness) {
  5830. if (this.color) {
  5831. context.strokeStyle = this.color;
  5832. }
  5833. context.lineWidth = this._thickness;
  5834. context.stroke();
  5835. }
  5836. context.restore();
  5837. };
  5838. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5839. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5840. this._measureForChildren.width -= 2 * this._thickness;
  5841. this._measureForChildren.height -= 2 * this._thickness;
  5842. this._measureForChildren.left += this._thickness;
  5843. this._measureForChildren.top += this._thickness;
  5844. };
  5845. Ellipse.prototype._clipForChildren = function (context) {
  5846. _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);
  5847. context.clip();
  5848. };
  5849. return Ellipse;
  5850. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5851. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5852. /***/ }),
  5853. /***/ "./2D/controls/grid.ts":
  5854. /*!*****************************!*\
  5855. !*** ./2D/controls/grid.ts ***!
  5856. \*****************************/
  5857. /*! exports provided: Grid */
  5858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5859. "use strict";
  5860. __webpack_require__.r(__webpack_exports__);
  5861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5862. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5863. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5864. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5865. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5866. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  5867. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5868. /**
  5869. * Class used to create a 2D grid container
  5870. */
  5871. var Grid = /** @class */ (function (_super) {
  5872. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5873. /**
  5874. * Creates a new Grid
  5875. * @param name defines control name
  5876. */
  5877. function Grid(name) {
  5878. var _this = _super.call(this, name) || this;
  5879. _this.name = name;
  5880. _this._rowDefinitions = new Array();
  5881. _this._columnDefinitions = new Array();
  5882. _this._cells = {};
  5883. _this._childControls = new Array();
  5884. return _this;
  5885. }
  5886. Object.defineProperty(Grid.prototype, "columnCount", {
  5887. /**
  5888. * Gets the number of columns
  5889. */
  5890. get: function () {
  5891. return this._columnDefinitions.length;
  5892. },
  5893. enumerable: false,
  5894. configurable: true
  5895. });
  5896. Object.defineProperty(Grid.prototype, "rowCount", {
  5897. /**
  5898. * Gets the number of rows
  5899. */
  5900. get: function () {
  5901. return this._rowDefinitions.length;
  5902. },
  5903. enumerable: false,
  5904. configurable: true
  5905. });
  5906. Object.defineProperty(Grid.prototype, "children", {
  5907. /** Gets the list of children */
  5908. get: function () {
  5909. return this._childControls;
  5910. },
  5911. enumerable: false,
  5912. configurable: true
  5913. });
  5914. Object.defineProperty(Grid.prototype, "cells", {
  5915. /** Gets the list of cells (e.g. the containers) */
  5916. get: function () {
  5917. return this._cells;
  5918. },
  5919. enumerable: false,
  5920. configurable: true
  5921. });
  5922. /**
  5923. * Gets the definition of a specific row
  5924. * @param index defines the index of the row
  5925. * @returns the row definition
  5926. */
  5927. Grid.prototype.getRowDefinition = function (index) {
  5928. if (index < 0 || index >= this._rowDefinitions.length) {
  5929. return null;
  5930. }
  5931. return this._rowDefinitions[index];
  5932. };
  5933. /**
  5934. * Gets the definition of a specific column
  5935. * @param index defines the index of the column
  5936. * @returns the column definition
  5937. */
  5938. Grid.prototype.getColumnDefinition = function (index) {
  5939. if (index < 0 || index >= this._columnDefinitions.length) {
  5940. return null;
  5941. }
  5942. return this._columnDefinitions[index];
  5943. };
  5944. /**
  5945. * Adds a new row to the grid
  5946. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5947. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5948. * @returns the current grid
  5949. */
  5950. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5951. if (isPixel === void 0) { isPixel = false; }
  5952. 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));
  5953. this._markAsDirty();
  5954. return this;
  5955. };
  5956. /**
  5957. * Adds a new column to the grid
  5958. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5959. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5960. * @returns the current grid
  5961. */
  5962. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5963. if (isPixel === void 0) { isPixel = false; }
  5964. 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));
  5965. this._markAsDirty();
  5966. return this;
  5967. };
  5968. /**
  5969. * Update a row definition
  5970. * @param index defines the index of the row to update
  5971. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5972. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5973. * @returns the current grid
  5974. */
  5975. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5976. if (isPixel === void 0) { isPixel = false; }
  5977. if (index < 0 || index >= this._rowDefinitions.length) {
  5978. return this;
  5979. }
  5980. var current = this._rowDefinitions[index];
  5981. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5982. return this;
  5983. }
  5984. 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);
  5985. this._markAsDirty();
  5986. return this;
  5987. };
  5988. /**
  5989. * Update a column definition
  5990. * @param index defines the index of the column to update
  5991. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5992. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5993. * @returns the current grid
  5994. */
  5995. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5996. if (isPixel === void 0) { isPixel = false; }
  5997. if (index < 0 || index >= this._columnDefinitions.length) {
  5998. return this;
  5999. }
  6000. var current = this._columnDefinitions[index];
  6001. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6002. return this;
  6003. }
  6004. 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);
  6005. this._markAsDirty();
  6006. return this;
  6007. };
  6008. /**
  6009. * Gets the list of children stored in a specific cell
  6010. * @param row defines the row to check
  6011. * @param column defines the column to check
  6012. * @returns the list of controls
  6013. */
  6014. Grid.prototype.getChildrenAt = function (row, column) {
  6015. var cell = this._cells[row + ":" + column];
  6016. if (!cell) {
  6017. return null;
  6018. }
  6019. return cell.children;
  6020. };
  6021. /**
  6022. * Gets a string representing the child cell info (row x column)
  6023. * @param child defines the control to get info from
  6024. * @returns a string containing the child cell info (row x column)
  6025. */
  6026. Grid.prototype.getChildCellInfo = function (child) {
  6027. return child._tag;
  6028. };
  6029. Grid.prototype._removeCell = function (cell, key) {
  6030. if (!cell) {
  6031. return;
  6032. }
  6033. _super.prototype.removeControl.call(this, cell);
  6034. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6035. var control = _a[_i];
  6036. var childIndex = this._childControls.indexOf(control);
  6037. if (childIndex !== -1) {
  6038. this._childControls.splice(childIndex, 1);
  6039. }
  6040. }
  6041. delete this._cells[key];
  6042. };
  6043. Grid.prototype._offsetCell = function (previousKey, key) {
  6044. if (!this._cells[key]) {
  6045. return;
  6046. }
  6047. this._cells[previousKey] = this._cells[key];
  6048. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6049. var control = _a[_i];
  6050. control._tag = previousKey;
  6051. }
  6052. delete this._cells[key];
  6053. };
  6054. /**
  6055. * Remove a column definition at specified index
  6056. * @param index defines the index of the column to remove
  6057. * @returns the current grid
  6058. */
  6059. Grid.prototype.removeColumnDefinition = function (index) {
  6060. if (index < 0 || index >= this._columnDefinitions.length) {
  6061. return this;
  6062. }
  6063. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6064. var key = x + ":" + index;
  6065. var cell = this._cells[key];
  6066. this._removeCell(cell, key);
  6067. }
  6068. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6069. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6070. var previousKey = x + ":" + (y - 1);
  6071. var key = x + ":" + y;
  6072. this._offsetCell(previousKey, key);
  6073. }
  6074. }
  6075. this._columnDefinitions.splice(index, 1);
  6076. this._markAsDirty();
  6077. return this;
  6078. };
  6079. /**
  6080. * Remove a row definition at specified index
  6081. * @param index defines the index of the row to remove
  6082. * @returns the current grid
  6083. */
  6084. Grid.prototype.removeRowDefinition = function (index) {
  6085. if (index < 0 || index >= this._rowDefinitions.length) {
  6086. return this;
  6087. }
  6088. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6089. var key = index + ":" + y;
  6090. var cell = this._cells[key];
  6091. this._removeCell(cell, key);
  6092. }
  6093. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6094. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6095. var previousKey = x - 1 + ":" + y;
  6096. var key = x + ":" + y;
  6097. this._offsetCell(previousKey, key);
  6098. }
  6099. }
  6100. this._rowDefinitions.splice(index, 1);
  6101. this._markAsDirty();
  6102. return this;
  6103. };
  6104. /**
  6105. * Adds a new control to the current grid
  6106. * @param control defines the control to add
  6107. * @param row defines the row where to add the control (0 by default)
  6108. * @param column defines the column where to add the control (0 by default)
  6109. * @returns the current grid
  6110. */
  6111. Grid.prototype.addControl = function (control, row, column) {
  6112. if (row === void 0) { row = 0; }
  6113. if (column === void 0) { column = 0; }
  6114. if (this._rowDefinitions.length === 0) {
  6115. // Add default row definition
  6116. this.addRowDefinition(1, false);
  6117. }
  6118. if (this._columnDefinitions.length === 0) {
  6119. // Add default column definition
  6120. this.addColumnDefinition(1, false);
  6121. }
  6122. if (this._childControls.indexOf(control) !== -1) {
  6123. 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");
  6124. return this;
  6125. }
  6126. var x = Math.min(row, this._rowDefinitions.length - 1);
  6127. var y = Math.min(column, this._columnDefinitions.length - 1);
  6128. var key = x + ":" + y;
  6129. var goodContainer = this._cells[key];
  6130. if (!goodContainer) {
  6131. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6132. this._cells[key] = goodContainer;
  6133. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6134. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6135. _super.prototype.addControl.call(this, goodContainer);
  6136. }
  6137. goodContainer.addControl(control);
  6138. this._childControls.push(control);
  6139. control._tag = key;
  6140. control.parent = this;
  6141. this._markAsDirty();
  6142. return this;
  6143. };
  6144. /**
  6145. * Removes a control from the current container
  6146. * @param control defines the control to remove
  6147. * @returns the current container
  6148. */
  6149. Grid.prototype.removeControl = function (control) {
  6150. var index = this._childControls.indexOf(control);
  6151. if (index !== -1) {
  6152. this._childControls.splice(index, 1);
  6153. }
  6154. var cell = this._cells[control._tag];
  6155. if (cell) {
  6156. cell.removeControl(control);
  6157. control._tag = null;
  6158. }
  6159. this._markAsDirty();
  6160. return this;
  6161. };
  6162. Grid.prototype._getTypeName = function () {
  6163. return "Grid";
  6164. };
  6165. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6166. var widths = [];
  6167. var heights = [];
  6168. var lefts = [];
  6169. var tops = [];
  6170. var availableWidth = this._currentMeasure.width;
  6171. var globalWidthPercentage = 0;
  6172. var availableHeight = this._currentMeasure.height;
  6173. var globalHeightPercentage = 0;
  6174. // Heights
  6175. var index = 0;
  6176. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6177. var value = _a[_i];
  6178. if (value.isPixel) {
  6179. var height = value.getValue(this._host);
  6180. availableHeight -= height;
  6181. heights[index] = height;
  6182. }
  6183. else {
  6184. globalHeightPercentage += value.internalValue;
  6185. }
  6186. index++;
  6187. }
  6188. var top = 0;
  6189. index = 0;
  6190. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6191. var value = _c[_b];
  6192. tops.push(top);
  6193. if (!value.isPixel) {
  6194. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6195. top += height;
  6196. heights[index] = height;
  6197. }
  6198. else {
  6199. top += value.getValue(this._host);
  6200. }
  6201. index++;
  6202. }
  6203. // Widths
  6204. index = 0;
  6205. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6206. var value = _e[_d];
  6207. if (value.isPixel) {
  6208. var width = value.getValue(this._host);
  6209. availableWidth -= width;
  6210. widths[index] = width;
  6211. }
  6212. else {
  6213. globalWidthPercentage += value.internalValue;
  6214. }
  6215. index++;
  6216. }
  6217. var left = 0;
  6218. index = 0;
  6219. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6220. var value = _g[_f];
  6221. lefts.push(left);
  6222. if (!value.isPixel) {
  6223. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6224. left += width;
  6225. widths[index] = width;
  6226. }
  6227. else {
  6228. left += value.getValue(this._host);
  6229. }
  6230. index++;
  6231. }
  6232. definitionCallback(lefts, tops, widths, heights);
  6233. };
  6234. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6235. var _this = this;
  6236. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6237. // Setting child sizes
  6238. for (var key in _this._cells) {
  6239. if (!_this._cells.hasOwnProperty(key)) {
  6240. continue;
  6241. }
  6242. var split = key.split(":");
  6243. var x = parseInt(split[0]);
  6244. var y = parseInt(split[1]);
  6245. var cell = _this._cells[key];
  6246. cell.left = lefts[y] + "px";
  6247. cell.top = tops[x] + "px";
  6248. cell.width = widths[y] + "px";
  6249. cell.height = heights[x] + "px";
  6250. cell._left.ignoreAdaptiveScaling = true;
  6251. cell._top.ignoreAdaptiveScaling = true;
  6252. cell._width.ignoreAdaptiveScaling = true;
  6253. cell._height.ignoreAdaptiveScaling = true;
  6254. }
  6255. });
  6256. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6257. };
  6258. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6259. for (var key in this._cells) {
  6260. if (!this._cells.hasOwnProperty(key)) {
  6261. continue;
  6262. }
  6263. var child = this._cells[key];
  6264. child._markMatrixAsDirty();
  6265. }
  6266. };
  6267. Grid.prototype._renderHighlightSpecific = function (context) {
  6268. var _this = this;
  6269. _super.prototype._renderHighlightSpecific.call(this, context);
  6270. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6271. // Columns
  6272. for (var index = 0; index < lefts.length; index++) {
  6273. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6274. context.beginPath();
  6275. context.moveTo(left, _this._currentMeasure.top);
  6276. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6277. context.stroke();
  6278. }
  6279. // Rows
  6280. for (var index = 0; index < tops.length; index++) {
  6281. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6282. context.beginPath();
  6283. context.moveTo(_this._currentMeasure.left, top_1);
  6284. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6285. context.stroke();
  6286. }
  6287. });
  6288. context.restore();
  6289. };
  6290. /** Releases associated resources */
  6291. Grid.prototype.dispose = function () {
  6292. _super.prototype.dispose.call(this);
  6293. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6294. var control = _a[_i];
  6295. control.dispose();
  6296. }
  6297. this._childControls = [];
  6298. };
  6299. return Grid;
  6300. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6301. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6302. /***/ }),
  6303. /***/ "./2D/controls/image.ts":
  6304. /*!******************************!*\
  6305. !*** ./2D/controls/image.ts ***!
  6306. \******************************/
  6307. /*! exports provided: Image */
  6308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6309. "use strict";
  6310. __webpack_require__.r(__webpack_exports__);
  6311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6312. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6313. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  6314. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6315. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6316. /**
  6317. * Class used to create 2D images
  6318. */
  6319. var Image = /** @class */ (function (_super) {
  6320. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6321. /**
  6322. * Creates a new Image
  6323. * @param name defines the control name
  6324. * @param url defines the image url
  6325. */
  6326. function Image(name, url) {
  6327. if (url === void 0) { url = null; }
  6328. var _this = _super.call(this, name) || this;
  6329. _this.name = name;
  6330. _this._workingCanvas = null;
  6331. _this._loaded = false;
  6332. _this._stretch = Image.STRETCH_FILL;
  6333. _this._autoScale = false;
  6334. _this._sourceLeft = 0;
  6335. _this._sourceTop = 0;
  6336. _this._sourceWidth = 0;
  6337. _this._sourceHeight = 0;
  6338. _this._svgAttributesComputationCompleted = false;
  6339. _this._isSVG = false;
  6340. _this._cellWidth = 0;
  6341. _this._cellHeight = 0;
  6342. _this._cellId = -1;
  6343. _this._populateNinePatchSlicesFromImage = false;
  6344. _this._imageDataCache = { data: null, key: "" };
  6345. /**
  6346. * Observable notified when the content is loaded
  6347. */
  6348. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6349. /**
  6350. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6351. */
  6352. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6353. _this.source = url;
  6354. return _this;
  6355. }
  6356. Object.defineProperty(Image.prototype, "isLoaded", {
  6357. /**
  6358. * Gets a boolean indicating that the content is loaded
  6359. */
  6360. get: function () {
  6361. return this._loaded;
  6362. },
  6363. enumerable: false,
  6364. configurable: true
  6365. });
  6366. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6367. /**
  6368. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6369. */
  6370. get: function () {
  6371. return this._populateNinePatchSlicesFromImage;
  6372. },
  6373. set: function (value) {
  6374. if (this._populateNinePatchSlicesFromImage === value) {
  6375. return;
  6376. }
  6377. this._populateNinePatchSlicesFromImage = value;
  6378. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6379. this._extractNinePatchSliceDataFromImage();
  6380. }
  6381. },
  6382. enumerable: false,
  6383. configurable: true
  6384. });
  6385. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6386. /**
  6387. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6388. * Beware using this as this will comsume more memory as the image has to be stored twice
  6389. */
  6390. get: function () {
  6391. return this._detectPointerOnOpaqueOnly;
  6392. },
  6393. set: function (value) {
  6394. if (this._detectPointerOnOpaqueOnly === value) {
  6395. return;
  6396. }
  6397. this._detectPointerOnOpaqueOnly = value;
  6398. },
  6399. enumerable: false,
  6400. configurable: true
  6401. });
  6402. Object.defineProperty(Image.prototype, "sliceLeft", {
  6403. /**
  6404. * Gets or sets the left value for slicing (9-patch)
  6405. */
  6406. get: function () {
  6407. return this._sliceLeft;
  6408. },
  6409. set: function (value) {
  6410. if (this._sliceLeft === value) {
  6411. return;
  6412. }
  6413. this._sliceLeft = value;
  6414. this._markAsDirty();
  6415. },
  6416. enumerable: false,
  6417. configurable: true
  6418. });
  6419. Object.defineProperty(Image.prototype, "sliceRight", {
  6420. /**
  6421. * Gets or sets the right value for slicing (9-patch)
  6422. */
  6423. get: function () {
  6424. return this._sliceRight;
  6425. },
  6426. set: function (value) {
  6427. if (this._sliceRight === value) {
  6428. return;
  6429. }
  6430. this._sliceRight = value;
  6431. this._markAsDirty();
  6432. },
  6433. enumerable: false,
  6434. configurable: true
  6435. });
  6436. Object.defineProperty(Image.prototype, "sliceTop", {
  6437. /**
  6438. * Gets or sets the top value for slicing (9-patch)
  6439. */
  6440. get: function () {
  6441. return this._sliceTop;
  6442. },
  6443. set: function (value) {
  6444. if (this._sliceTop === value) {
  6445. return;
  6446. }
  6447. this._sliceTop = value;
  6448. this._markAsDirty();
  6449. },
  6450. enumerable: false,
  6451. configurable: true
  6452. });
  6453. Object.defineProperty(Image.prototype, "sliceBottom", {
  6454. /**
  6455. * Gets or sets the bottom value for slicing (9-patch)
  6456. */
  6457. get: function () {
  6458. return this._sliceBottom;
  6459. },
  6460. set: function (value) {
  6461. if (this._sliceBottom === value) {
  6462. return;
  6463. }
  6464. this._sliceBottom = value;
  6465. this._markAsDirty();
  6466. },
  6467. enumerable: false,
  6468. configurable: true
  6469. });
  6470. Object.defineProperty(Image.prototype, "sourceLeft", {
  6471. /**
  6472. * Gets or sets the left coordinate in the source image
  6473. */
  6474. get: function () {
  6475. return this._sourceLeft;
  6476. },
  6477. set: function (value) {
  6478. if (this._sourceLeft === value) {
  6479. return;
  6480. }
  6481. this._sourceLeft = value;
  6482. this._markAsDirty();
  6483. },
  6484. enumerable: false,
  6485. configurable: true
  6486. });
  6487. Object.defineProperty(Image.prototype, "sourceTop", {
  6488. /**
  6489. * Gets or sets the top coordinate in the source image
  6490. */
  6491. get: function () {
  6492. return this._sourceTop;
  6493. },
  6494. set: function (value) {
  6495. if (this._sourceTop === value) {
  6496. return;
  6497. }
  6498. this._sourceTop = value;
  6499. this._markAsDirty();
  6500. },
  6501. enumerable: false,
  6502. configurable: true
  6503. });
  6504. Object.defineProperty(Image.prototype, "sourceWidth", {
  6505. /**
  6506. * Gets or sets the width to capture in the source image
  6507. */
  6508. get: function () {
  6509. return this._sourceWidth;
  6510. },
  6511. set: function (value) {
  6512. if (this._sourceWidth === value) {
  6513. return;
  6514. }
  6515. this._sourceWidth = value;
  6516. this._markAsDirty();
  6517. },
  6518. enumerable: false,
  6519. configurable: true
  6520. });
  6521. Object.defineProperty(Image.prototype, "sourceHeight", {
  6522. /**
  6523. * Gets or sets the height to capture in the source image
  6524. */
  6525. get: function () {
  6526. return this._sourceHeight;
  6527. },
  6528. set: function (value) {
  6529. if (this._sourceHeight === value) {
  6530. return;
  6531. }
  6532. this._sourceHeight = value;
  6533. this._markAsDirty();
  6534. },
  6535. enumerable: false,
  6536. configurable: true
  6537. });
  6538. Object.defineProperty(Image.prototype, "isSVG", {
  6539. /** Indicates if the format of the image is SVG */
  6540. get: function () {
  6541. return this._isSVG;
  6542. },
  6543. enumerable: false,
  6544. configurable: true
  6545. });
  6546. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6547. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6548. get: function () {
  6549. return this._svgAttributesComputationCompleted;
  6550. },
  6551. enumerable: false,
  6552. configurable: true
  6553. });
  6554. Object.defineProperty(Image.prototype, "autoScale", {
  6555. /**
  6556. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6557. * @see https://doc.babylonjs.com/how_to/gui#image
  6558. */
  6559. get: function () {
  6560. return this._autoScale;
  6561. },
  6562. set: function (value) {
  6563. if (this._autoScale === value) {
  6564. return;
  6565. }
  6566. this._autoScale = value;
  6567. if (value && this._loaded) {
  6568. this.synchronizeSizeWithContent();
  6569. }
  6570. },
  6571. enumerable: false,
  6572. configurable: true
  6573. });
  6574. Object.defineProperty(Image.prototype, "stretch", {
  6575. /** Gets or sets the streching mode used by the image */
  6576. get: function () {
  6577. return this._stretch;
  6578. },
  6579. set: function (value) {
  6580. if (this._stretch === value) {
  6581. return;
  6582. }
  6583. this._stretch = value;
  6584. this._markAsDirty();
  6585. },
  6586. enumerable: false,
  6587. configurable: true
  6588. });
  6589. /** @hidden */
  6590. Image.prototype._rotate90 = function (n, preserveProperties) {
  6591. if (preserveProperties === void 0) { preserveProperties = false; }
  6592. var canvas = document.createElement('canvas');
  6593. var context = canvas.getContext('2d');
  6594. var width = this._domImage.width;
  6595. var height = this._domImage.height;
  6596. canvas.width = height;
  6597. canvas.height = width;
  6598. context.translate(canvas.width / 2, canvas.height / 2);
  6599. context.rotate(n * Math.PI / 2);
  6600. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6601. var dataUrl = canvas.toDataURL("image/jpg");
  6602. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6603. if (preserveProperties) {
  6604. rotatedImage._stretch = this._stretch;
  6605. rotatedImage._autoScale = this._autoScale;
  6606. rotatedImage._cellId = this._cellId;
  6607. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6608. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6609. }
  6610. this._handleRotationForSVGImage(this, rotatedImage, n);
  6611. this._imageDataCache.data = null;
  6612. return rotatedImage;
  6613. };
  6614. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6615. var _this = this;
  6616. if (!srcImage._isSVG) {
  6617. return;
  6618. }
  6619. if (srcImage._svgAttributesComputationCompleted) {
  6620. this._rotate90SourceProperties(srcImage, dstImage, n);
  6621. this._markAsDirty();
  6622. }
  6623. else {
  6624. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6625. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6626. _this._markAsDirty();
  6627. });
  6628. }
  6629. };
  6630. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6631. var _a, _b;
  6632. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6633. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6634. if (n != 0) {
  6635. var mult = n < 0 ? -1 : 1;
  6636. n = n % 4;
  6637. for (var i = 0; i < Math.abs(n); ++i) {
  6638. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6639. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6640. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6641. if (n < 0) {
  6642. dstTop -= dstHeight;
  6643. }
  6644. else {
  6645. dstLeft -= dstWidth;
  6646. }
  6647. srcLeft = dstLeft;
  6648. srcTop = dstTop;
  6649. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6650. }
  6651. }
  6652. dstImage.sourceLeft = dstLeft;
  6653. dstImage.sourceTop = dstTop;
  6654. dstImage.sourceWidth = dstWidth;
  6655. dstImage.sourceHeight = dstHeight;
  6656. };
  6657. Object.defineProperty(Image.prototype, "domImage", {
  6658. get: function () {
  6659. return this._domImage;
  6660. },
  6661. /**
  6662. * Gets or sets the internal DOM image used to render the control
  6663. */
  6664. set: function (value) {
  6665. var _this = this;
  6666. this._domImage = value;
  6667. this._loaded = false;
  6668. this._imageDataCache.data = null;
  6669. if (this._domImage.width) {
  6670. this._onImageLoaded();
  6671. }
  6672. else {
  6673. this._domImage.onload = function () {
  6674. _this._onImageLoaded();
  6675. };
  6676. }
  6677. },
  6678. enumerable: false,
  6679. configurable: true
  6680. });
  6681. Image.prototype._onImageLoaded = function () {
  6682. this._imageWidth = this._domImage.width;
  6683. this._imageHeight = this._domImage.height;
  6684. this._loaded = true;
  6685. if (this._populateNinePatchSlicesFromImage) {
  6686. this._extractNinePatchSliceDataFromImage();
  6687. }
  6688. if (this._autoScale) {
  6689. this.synchronizeSizeWithContent();
  6690. }
  6691. this.onImageLoadedObservable.notifyObservers(this);
  6692. this._markAsDirty();
  6693. };
  6694. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6695. if (!this._workingCanvas) {
  6696. this._workingCanvas = document.createElement('canvas');
  6697. }
  6698. var canvas = this._workingCanvas;
  6699. var context = canvas.getContext('2d');
  6700. var width = this._domImage.width;
  6701. var height = this._domImage.height;
  6702. canvas.width = width;
  6703. canvas.height = height;
  6704. context.drawImage(this._domImage, 0, 0, width, height);
  6705. var imageData = context.getImageData(0, 0, width, height);
  6706. // Left and right
  6707. this._sliceLeft = -1;
  6708. this._sliceRight = -1;
  6709. for (var x = 0; x < width; x++) {
  6710. var alpha = imageData.data[x * 4 + 3];
  6711. if (alpha > 127 && this._sliceLeft === -1) {
  6712. this._sliceLeft = x;
  6713. continue;
  6714. }
  6715. if (alpha < 127 && this._sliceLeft > -1) {
  6716. this._sliceRight = x;
  6717. break;
  6718. }
  6719. }
  6720. // top and bottom
  6721. this._sliceTop = -1;
  6722. this._sliceBottom = -1;
  6723. for (var y = 0; y < height; y++) {
  6724. var alpha = imageData.data[y * width * 4 + 3];
  6725. if (alpha > 127 && this._sliceTop === -1) {
  6726. this._sliceTop = y;
  6727. continue;
  6728. }
  6729. if (alpha < 127 && this._sliceTop > -1) {
  6730. this._sliceBottom = y;
  6731. break;
  6732. }
  6733. }
  6734. };
  6735. Object.defineProperty(Image.prototype, "source", {
  6736. /**
  6737. * Gets or sets image source url
  6738. */
  6739. set: function (value) {
  6740. var _this = this;
  6741. if (this._source === value) {
  6742. return;
  6743. }
  6744. this._loaded = false;
  6745. this._source = value;
  6746. this._imageDataCache.data = null;
  6747. if (value) {
  6748. value = this._svgCheck(value);
  6749. }
  6750. this._domImage = document.createElement("img");
  6751. this._domImage.onload = function () {
  6752. _this._onImageLoaded();
  6753. };
  6754. if (value) {
  6755. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6756. this._domImage.src = value;
  6757. }
  6758. },
  6759. enumerable: false,
  6760. configurable: true
  6761. });
  6762. /**
  6763. * Checks for svg document with icon id present
  6764. */
  6765. Image.prototype._svgCheck = function (value) {
  6766. var _this = this;
  6767. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6768. this._isSVG = true;
  6769. var svgsrc = value.split('#')[0];
  6770. var elemid = value.split('#')[1];
  6771. // check if object alr exist in document
  6772. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6773. if (svgExist) {
  6774. var svgDoc = svgExist.contentDocument;
  6775. // get viewbox width and height, get svg document width and height in px
  6776. if (svgDoc && svgDoc.documentElement) {
  6777. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6778. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6779. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6780. var elem = svgDoc.getElementById(elemid);
  6781. if (elem && vb && docwidth && docheight) {
  6782. this._getSVGAttribs(svgExist, elemid);
  6783. return value;
  6784. }
  6785. }
  6786. // wait for object to load
  6787. svgExist.addEventListener("load", function () {
  6788. _this._getSVGAttribs(svgExist, elemid);
  6789. });
  6790. }
  6791. else {
  6792. // create document object
  6793. var svgImage = document.createElement("object");
  6794. svgImage.data = svgsrc;
  6795. svgImage.type = "image/svg+xml";
  6796. svgImage.width = "0%";
  6797. svgImage.height = "0%";
  6798. document.body.appendChild(svgImage);
  6799. // when the object has loaded, get the element attribs
  6800. svgImage.onload = function () {
  6801. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6802. if (svgobj) {
  6803. _this._getSVGAttribs(svgobj, elemid);
  6804. }
  6805. };
  6806. }
  6807. return svgsrc;
  6808. }
  6809. else {
  6810. return value;
  6811. }
  6812. };
  6813. /**
  6814. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6815. * given external svg file and icon id
  6816. */
  6817. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6818. var svgDoc = svgsrc.contentDocument;
  6819. // get viewbox width and height, get svg document width and height in px
  6820. if (svgDoc && svgDoc.documentElement) {
  6821. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6822. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6823. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6824. // get element bbox and matrix transform
  6825. var elem = svgDoc.getElementById(elemid);
  6826. if (vb && docwidth && docheight && elem) {
  6827. var vb_width = Number(vb.split(" ")[2]);
  6828. var vb_height = Number(vb.split(" ")[3]);
  6829. var elem_bbox = elem.getBBox();
  6830. var elem_matrix_a = 1;
  6831. var elem_matrix_d = 1;
  6832. var elem_matrix_e = 0;
  6833. var elem_matrix_f = 0;
  6834. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6835. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6836. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6837. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6838. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6839. }
  6840. // compute source coordinates and dimensions
  6841. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6842. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6843. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6844. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6845. this._svgAttributesComputationCompleted = true;
  6846. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6847. }
  6848. }
  6849. };
  6850. Object.defineProperty(Image.prototype, "cellWidth", {
  6851. /**
  6852. * Gets or sets the cell width to use when animation sheet is enabled
  6853. * @see https://doc.babylonjs.com/how_to/gui#image
  6854. */
  6855. get: function () {
  6856. return this._cellWidth;
  6857. },
  6858. set: function (value) {
  6859. if (this._cellWidth === value) {
  6860. return;
  6861. }
  6862. this._cellWidth = value;
  6863. this._markAsDirty();
  6864. },
  6865. enumerable: false,
  6866. configurable: true
  6867. });
  6868. Object.defineProperty(Image.prototype, "cellHeight", {
  6869. /**
  6870. * Gets or sets the cell height to use when animation sheet is enabled
  6871. * @see https://doc.babylonjs.com/how_to/gui#image
  6872. */
  6873. get: function () {
  6874. return this._cellHeight;
  6875. },
  6876. set: function (value) {
  6877. if (this._cellHeight === value) {
  6878. return;
  6879. }
  6880. this._cellHeight = value;
  6881. this._markAsDirty();
  6882. },
  6883. enumerable: false,
  6884. configurable: true
  6885. });
  6886. Object.defineProperty(Image.prototype, "cellId", {
  6887. /**
  6888. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6889. * @see https://doc.babylonjs.com/how_to/gui#image
  6890. */
  6891. get: function () {
  6892. return this._cellId;
  6893. },
  6894. set: function (value) {
  6895. if (this._cellId === value) {
  6896. return;
  6897. }
  6898. this._cellId = value;
  6899. this._markAsDirty();
  6900. },
  6901. enumerable: false,
  6902. configurable: true
  6903. });
  6904. /**
  6905. * Tests if a given coordinates belong to the current control
  6906. * @param x defines x coordinate to test
  6907. * @param y defines y coordinate to test
  6908. * @returns true if the coordinates are inside the control
  6909. */
  6910. Image.prototype.contains = function (x, y) {
  6911. if (!_super.prototype.contains.call(this, x, y)) {
  6912. return false;
  6913. }
  6914. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6915. return true;
  6916. }
  6917. var width = this._currentMeasure.width | 0;
  6918. var height = this._currentMeasure.height | 0;
  6919. var key = width + "_" + height;
  6920. var imageData = this._imageDataCache.data;
  6921. if (!imageData || this._imageDataCache.key !== key) {
  6922. var canvas = this._workingCanvas;
  6923. var context_1 = canvas.getContext("2d");
  6924. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  6925. }
  6926. x = (x - this._currentMeasure.left) | 0;
  6927. y = (y - this._currentMeasure.top) | 0;
  6928. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  6929. return pickedPixel > 0;
  6930. };
  6931. Image.prototype._getTypeName = function () {
  6932. return "Image";
  6933. };
  6934. /** Force the control to synchronize with its content */
  6935. Image.prototype.synchronizeSizeWithContent = function () {
  6936. if (!this._loaded) {
  6937. return;
  6938. }
  6939. this.width = this._domImage.width + "px";
  6940. this.height = this._domImage.height + "px";
  6941. };
  6942. Image.prototype._processMeasures = function (parentMeasure, context) {
  6943. if (this._loaded) {
  6944. switch (this._stretch) {
  6945. case Image.STRETCH_NONE:
  6946. break;
  6947. case Image.STRETCH_FILL:
  6948. break;
  6949. case Image.STRETCH_UNIFORM:
  6950. break;
  6951. case Image.STRETCH_NINE_PATCH:
  6952. break;
  6953. case Image.STRETCH_EXTEND:
  6954. if (this._autoScale) {
  6955. this.synchronizeSizeWithContent();
  6956. }
  6957. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6958. this.parent.adaptWidthToChildren = true;
  6959. this.parent.adaptHeightToChildren = true;
  6960. }
  6961. break;
  6962. }
  6963. }
  6964. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6965. };
  6966. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6967. if (!this._detectPointerOnOpaqueOnly) {
  6968. return;
  6969. }
  6970. if (!this._workingCanvas) {
  6971. this._workingCanvas = document.createElement('canvas');
  6972. }
  6973. var canvas = this._workingCanvas;
  6974. var width = this._currentMeasure.width;
  6975. var height = this._currentMeasure.height;
  6976. var context = canvas.getContext("2d");
  6977. canvas.width = width;
  6978. canvas.height = height;
  6979. context.clearRect(0, 0, width, height);
  6980. };
  6981. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6982. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6983. if (!this._detectPointerOnOpaqueOnly) {
  6984. return;
  6985. }
  6986. var canvas = this._workingCanvas;
  6987. context = canvas.getContext("2d");
  6988. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6989. };
  6990. Image.prototype._draw = function (context) {
  6991. context.save();
  6992. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6993. context.shadowColor = this.shadowColor;
  6994. context.shadowBlur = this.shadowBlur;
  6995. context.shadowOffsetX = this.shadowOffsetX;
  6996. context.shadowOffsetY = this.shadowOffsetY;
  6997. }
  6998. var x, y, width, height;
  6999. if (this.cellId == -1) {
  7000. x = this._sourceLeft;
  7001. y = this._sourceTop;
  7002. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7003. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7004. }
  7005. else {
  7006. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7007. var column = (this.cellId / rowCount) >> 0;
  7008. var row = this.cellId % rowCount;
  7009. x = this.cellWidth * row;
  7010. y = this.cellHeight * column;
  7011. width = this.cellWidth;
  7012. height = this.cellHeight;
  7013. }
  7014. this._prepareWorkingCanvasForOpaqueDetection();
  7015. this._applyStates(context);
  7016. if (this._loaded) {
  7017. switch (this._stretch) {
  7018. case Image.STRETCH_NONE:
  7019. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7020. break;
  7021. case Image.STRETCH_FILL:
  7022. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7023. break;
  7024. case Image.STRETCH_UNIFORM:
  7025. var hRatio = this._currentMeasure.width / width;
  7026. var vRatio = this._currentMeasure.height / height;
  7027. var ratio = Math.min(hRatio, vRatio);
  7028. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7029. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7030. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7031. break;
  7032. case Image.STRETCH_EXTEND:
  7033. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7034. break;
  7035. case Image.STRETCH_NINE_PATCH:
  7036. this._renderNinePatch(context);
  7037. break;
  7038. }
  7039. }
  7040. context.restore();
  7041. };
  7042. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7043. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7044. };
  7045. Image.prototype._renderNinePatch = function (context) {
  7046. var height = this._imageHeight;
  7047. var leftWidth = this._sliceLeft;
  7048. var topHeight = this._sliceTop;
  7049. var bottomHeight = this._imageHeight - this._sliceBottom;
  7050. var rightWidth = this._imageWidth - this._sliceRight;
  7051. var left = 0;
  7052. var top = 0;
  7053. if (this._populateNinePatchSlicesFromImage) {
  7054. left = 1;
  7055. top = 1;
  7056. height -= 2;
  7057. leftWidth -= 1;
  7058. topHeight -= 1;
  7059. bottomHeight -= 1;
  7060. rightWidth -= 1;
  7061. }
  7062. var centerWidth = this._sliceRight - this._sliceLeft;
  7063. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7064. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7065. // Corners
  7066. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7067. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7068. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7069. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7070. // Center
  7071. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7072. // Borders
  7073. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7074. 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);
  7075. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7076. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7077. };
  7078. Image.prototype.dispose = function () {
  7079. _super.prototype.dispose.call(this);
  7080. this.onImageLoadedObservable.clear();
  7081. this.onSVGAttributesComputedObservable.clear();
  7082. };
  7083. // Static
  7084. /** STRETCH_NONE */
  7085. Image.STRETCH_NONE = 0;
  7086. /** STRETCH_FILL */
  7087. Image.STRETCH_FILL = 1;
  7088. /** STRETCH_UNIFORM */
  7089. Image.STRETCH_UNIFORM = 2;
  7090. /** STRETCH_EXTEND */
  7091. Image.STRETCH_EXTEND = 3;
  7092. /** NINE_PATCH */
  7093. Image.STRETCH_NINE_PATCH = 4;
  7094. return Image;
  7095. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7096. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7097. /***/ }),
  7098. /***/ "./2D/controls/index.ts":
  7099. /*!******************************!*\
  7100. !*** ./2D/controls/index.ts ***!
  7101. \******************************/
  7102. /*! 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 */
  7103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7104. "use strict";
  7105. __webpack_require__.r(__webpack_exports__);
  7106. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7108. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7110. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7112. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7114. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7116. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7118. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7120. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7122. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7124. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7126. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7128. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7130. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7132. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7134. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7140. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7142. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7145. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7148. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7150. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7152. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7154. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7156. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7158. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7160. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7162. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7164. /***/ }),
  7165. /***/ "./2D/controls/inputPassword.ts":
  7166. /*!**************************************!*\
  7167. !*** ./2D/controls/inputPassword.ts ***!
  7168. \**************************************/
  7169. /*! exports provided: InputPassword */
  7170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7171. "use strict";
  7172. __webpack_require__.r(__webpack_exports__);
  7173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7175. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7176. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  7177. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7178. /**
  7179. * Class used to create a password control
  7180. */
  7181. var InputPassword = /** @class */ (function (_super) {
  7182. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7183. function InputPassword() {
  7184. return _super !== null && _super.apply(this, arguments) || this;
  7185. }
  7186. InputPassword.prototype._beforeRenderText = function (text) {
  7187. var txt = "";
  7188. for (var i = 0; i < text.length; i++) {
  7189. txt += "\u2022";
  7190. }
  7191. return txt;
  7192. };
  7193. return InputPassword;
  7194. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7195. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7196. /***/ }),
  7197. /***/ "./2D/controls/inputText.ts":
  7198. /*!**********************************!*\
  7199. !*** ./2D/controls/inputText.ts ***!
  7200. \**********************************/
  7201. /*! exports provided: InputText */
  7202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7203. "use strict";
  7204. __webpack_require__.r(__webpack_exports__);
  7205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7207. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  7208. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7209. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7210. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7211. /**
  7212. * Class used to create input text control
  7213. */
  7214. var InputText = /** @class */ (function (_super) {
  7215. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7216. /**
  7217. * Creates a new InputText
  7218. * @param name defines the control name
  7219. * @param text defines the text of the control
  7220. */
  7221. function InputText(name, text) {
  7222. if (text === void 0) { text = ""; }
  7223. var _this = _super.call(this, name) || this;
  7224. _this.name = name;
  7225. _this._text = "";
  7226. _this._placeholderText = "";
  7227. _this._background = "#222222";
  7228. _this._focusedBackground = "#000000";
  7229. _this._focusedColor = "white";
  7230. _this._placeholderColor = "gray";
  7231. _this._thickness = 1;
  7232. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7233. _this._autoStretchWidth = true;
  7234. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7235. _this._isFocused = false;
  7236. _this._blinkIsEven = false;
  7237. _this._cursorOffset = 0;
  7238. _this._deadKey = false;
  7239. _this._addKey = true;
  7240. _this._currentKey = "";
  7241. _this._isTextHighlightOn = false;
  7242. _this._textHighlightColor = "#d5e0ff";
  7243. _this._highligherOpacity = 0.4;
  7244. _this._highlightedText = "";
  7245. _this._startHighlightIndex = 0;
  7246. _this._endHighlightIndex = 0;
  7247. _this._cursorIndex = -1;
  7248. _this._onFocusSelectAll = false;
  7249. _this._isPointerDown = false;
  7250. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7251. _this.promptMessage = "Please enter text:";
  7252. /** Force disable prompt on mobile device */
  7253. _this.disableMobilePrompt = false;
  7254. /** Observable raised when the text changes */
  7255. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7256. /** Observable raised just before an entered character is to be added */
  7257. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7258. /** Observable raised when the control gets the focus */
  7259. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7260. /** Observable raised when the control loses the focus */
  7261. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7262. /**Observable raised when the text is highlighted */
  7263. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7264. /**Observable raised when copy event is triggered */
  7265. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7266. /** Observable raised when cut event is triggered */
  7267. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7268. /** Observable raised when paste event is triggered */
  7269. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7270. /** Observable raised when a key event was processed */
  7271. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7272. _this.text = text;
  7273. _this.isPointerBlocker = true;
  7274. return _this;
  7275. }
  7276. Object.defineProperty(InputText.prototype, "maxWidth", {
  7277. /** Gets or sets the maximum width allowed by the control */
  7278. get: function () {
  7279. return this._maxWidth.toString(this._host);
  7280. },
  7281. set: function (value) {
  7282. if (this._maxWidth.toString(this._host) === value) {
  7283. return;
  7284. }
  7285. if (this._maxWidth.fromString(value)) {
  7286. this._markAsDirty();
  7287. }
  7288. },
  7289. enumerable: false,
  7290. configurable: true
  7291. });
  7292. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7293. /** Gets the maximum width allowed by the control in pixels */
  7294. get: function () {
  7295. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7296. },
  7297. enumerable: false,
  7298. configurable: true
  7299. });
  7300. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7301. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7302. get: function () {
  7303. return this._highligherOpacity;
  7304. },
  7305. set: function (value) {
  7306. if (this._highligherOpacity === value) {
  7307. return;
  7308. }
  7309. this._highligherOpacity = value;
  7310. this._markAsDirty();
  7311. },
  7312. enumerable: false,
  7313. configurable: true
  7314. });
  7315. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7316. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7317. get: function () {
  7318. return this._onFocusSelectAll;
  7319. },
  7320. set: function (value) {
  7321. if (this._onFocusSelectAll === value) {
  7322. return;
  7323. }
  7324. this._onFocusSelectAll = value;
  7325. this._markAsDirty();
  7326. },
  7327. enumerable: false,
  7328. configurable: true
  7329. });
  7330. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7331. /** Gets or sets the text hightlight color */
  7332. get: function () {
  7333. return this._textHighlightColor;
  7334. },
  7335. set: function (value) {
  7336. if (this._textHighlightColor === value) {
  7337. return;
  7338. }
  7339. this._textHighlightColor = value;
  7340. this._markAsDirty();
  7341. },
  7342. enumerable: false,
  7343. configurable: true
  7344. });
  7345. Object.defineProperty(InputText.prototype, "margin", {
  7346. /** Gets or sets control margin */
  7347. get: function () {
  7348. return this._margin.toString(this._host);
  7349. },
  7350. set: function (value) {
  7351. if (this._margin.toString(this._host) === value) {
  7352. return;
  7353. }
  7354. if (this._margin.fromString(value)) {
  7355. this._markAsDirty();
  7356. }
  7357. },
  7358. enumerable: false,
  7359. configurable: true
  7360. });
  7361. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7362. /** Gets control margin in pixels */
  7363. get: function () {
  7364. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7365. },
  7366. enumerable: false,
  7367. configurable: true
  7368. });
  7369. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7370. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7371. get: function () {
  7372. return this._autoStretchWidth;
  7373. },
  7374. set: function (value) {
  7375. if (this._autoStretchWidth === value) {
  7376. return;
  7377. }
  7378. this._autoStretchWidth = value;
  7379. this._markAsDirty();
  7380. },
  7381. enumerable: false,
  7382. configurable: true
  7383. });
  7384. Object.defineProperty(InputText.prototype, "thickness", {
  7385. /** Gets or sets border thickness */
  7386. get: function () {
  7387. return this._thickness;
  7388. },
  7389. set: function (value) {
  7390. if (this._thickness === value) {
  7391. return;
  7392. }
  7393. this._thickness = value;
  7394. this._markAsDirty();
  7395. },
  7396. enumerable: false,
  7397. configurable: true
  7398. });
  7399. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7400. /** Gets or sets the background color when focused */
  7401. get: function () {
  7402. return this._focusedBackground;
  7403. },
  7404. set: function (value) {
  7405. if (this._focusedBackground === value) {
  7406. return;
  7407. }
  7408. this._focusedBackground = value;
  7409. this._markAsDirty();
  7410. },
  7411. enumerable: false,
  7412. configurable: true
  7413. });
  7414. Object.defineProperty(InputText.prototype, "focusedColor", {
  7415. /** Gets or sets the background color when focused */
  7416. get: function () {
  7417. return this._focusedColor;
  7418. },
  7419. set: function (value) {
  7420. if (this._focusedColor === value) {
  7421. return;
  7422. }
  7423. this._focusedColor = value;
  7424. this._markAsDirty();
  7425. },
  7426. enumerable: false,
  7427. configurable: true
  7428. });
  7429. Object.defineProperty(InputText.prototype, "background", {
  7430. /** Gets or sets the background color */
  7431. get: function () {
  7432. return this._background;
  7433. },
  7434. set: function (value) {
  7435. if (this._background === value) {
  7436. return;
  7437. }
  7438. this._background = value;
  7439. this._markAsDirty();
  7440. },
  7441. enumerable: false,
  7442. configurable: true
  7443. });
  7444. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7445. /** Gets or sets the placeholder color */
  7446. get: function () {
  7447. return this._placeholderColor;
  7448. },
  7449. set: function (value) {
  7450. if (this._placeholderColor === value) {
  7451. return;
  7452. }
  7453. this._placeholderColor = value;
  7454. this._markAsDirty();
  7455. },
  7456. enumerable: false,
  7457. configurable: true
  7458. });
  7459. Object.defineProperty(InputText.prototype, "placeholderText", {
  7460. /** Gets or sets the text displayed when the control is empty */
  7461. get: function () {
  7462. return this._placeholderText;
  7463. },
  7464. set: function (value) {
  7465. if (this._placeholderText === value) {
  7466. return;
  7467. }
  7468. this._placeholderText = value;
  7469. this._markAsDirty();
  7470. },
  7471. enumerable: false,
  7472. configurable: true
  7473. });
  7474. Object.defineProperty(InputText.prototype, "deadKey", {
  7475. /** Gets or sets the dead key flag */
  7476. get: function () {
  7477. return this._deadKey;
  7478. },
  7479. set: function (flag) {
  7480. this._deadKey = flag;
  7481. },
  7482. enumerable: false,
  7483. configurable: true
  7484. });
  7485. Object.defineProperty(InputText.prototype, "highlightedText", {
  7486. /** Gets or sets the highlight text */
  7487. get: function () {
  7488. return this._highlightedText;
  7489. },
  7490. set: function (text) {
  7491. if (this._highlightedText === text) {
  7492. return;
  7493. }
  7494. this._highlightedText = text;
  7495. this._markAsDirty();
  7496. },
  7497. enumerable: false,
  7498. configurable: true
  7499. });
  7500. Object.defineProperty(InputText.prototype, "addKey", {
  7501. /** Gets or sets if the current key should be added */
  7502. get: function () {
  7503. return this._addKey;
  7504. },
  7505. set: function (flag) {
  7506. this._addKey = flag;
  7507. },
  7508. enumerable: false,
  7509. configurable: true
  7510. });
  7511. Object.defineProperty(InputText.prototype, "currentKey", {
  7512. /** Gets or sets the value of the current key being entered */
  7513. get: function () {
  7514. return this._currentKey;
  7515. },
  7516. set: function (key) {
  7517. this._currentKey = key;
  7518. },
  7519. enumerable: false,
  7520. configurable: true
  7521. });
  7522. Object.defineProperty(InputText.prototype, "text", {
  7523. /** Gets or sets the text displayed in the control */
  7524. get: function () {
  7525. return this._text;
  7526. },
  7527. set: function (value) {
  7528. var valueAsString = value.toString(); // Forcing convertion
  7529. if (this._text === valueAsString) {
  7530. return;
  7531. }
  7532. this._text = valueAsString;
  7533. this._markAsDirty();
  7534. this.onTextChangedObservable.notifyObservers(this);
  7535. },
  7536. enumerable: false,
  7537. configurable: true
  7538. });
  7539. Object.defineProperty(InputText.prototype, "width", {
  7540. /** Gets or sets control width */
  7541. get: function () {
  7542. return this._width.toString(this._host);
  7543. },
  7544. set: function (value) {
  7545. if (this._width.toString(this._host) === value) {
  7546. return;
  7547. }
  7548. if (this._width.fromString(value)) {
  7549. this._markAsDirty();
  7550. }
  7551. this.autoStretchWidth = false;
  7552. },
  7553. enumerable: false,
  7554. configurable: true
  7555. });
  7556. /** @hidden */
  7557. InputText.prototype.onBlur = function () {
  7558. this._isFocused = false;
  7559. this._scrollLeft = null;
  7560. this._cursorOffset = 0;
  7561. clearTimeout(this._blinkTimeout);
  7562. this._markAsDirty();
  7563. this.onBlurObservable.notifyObservers(this);
  7564. this._host.unRegisterClipboardEvents();
  7565. if (this._onClipboardObserver) {
  7566. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7567. }
  7568. var scene = this._host.getScene();
  7569. if (this._onPointerDblTapObserver && scene) {
  7570. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7571. }
  7572. };
  7573. /** @hidden */
  7574. InputText.prototype.onFocus = function () {
  7575. var _this = this;
  7576. if (!this._isEnabled) {
  7577. return;
  7578. }
  7579. this._scrollLeft = null;
  7580. this._isFocused = true;
  7581. this._blinkIsEven = false;
  7582. this._cursorOffset = 0;
  7583. this._markAsDirty();
  7584. this.onFocusObservable.notifyObservers(this);
  7585. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7586. var value = prompt(this.promptMessage);
  7587. if (value !== null) {
  7588. this.text = value;
  7589. }
  7590. this._host.focusedControl = null;
  7591. return;
  7592. }
  7593. this._host.registerClipboardEvents();
  7594. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7595. // process clipboard event, can be configured.
  7596. switch (clipboardInfo.type) {
  7597. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7598. _this._onCopyText(clipboardInfo.event);
  7599. _this.onTextCopyObservable.notifyObservers(_this);
  7600. break;
  7601. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7602. _this._onCutText(clipboardInfo.event);
  7603. _this.onTextCutObservable.notifyObservers(_this);
  7604. break;
  7605. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7606. _this._onPasteText(clipboardInfo.event);
  7607. _this.onTextPasteObservable.notifyObservers(_this);
  7608. break;
  7609. default: return;
  7610. }
  7611. });
  7612. var scene = this._host.getScene();
  7613. if (scene) {
  7614. //register the pointer double tap event
  7615. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7616. if (!_this._isFocused) {
  7617. return;
  7618. }
  7619. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7620. _this._processDblClick(pointerInfo);
  7621. }
  7622. });
  7623. }
  7624. if (this._onFocusSelectAll) {
  7625. this._selectAllText();
  7626. }
  7627. };
  7628. InputText.prototype._getTypeName = function () {
  7629. return "InputText";
  7630. };
  7631. /**
  7632. * Function called to get the list of controls that should not steal the focus from this control
  7633. * @returns an array of controls
  7634. */
  7635. InputText.prototype.keepsFocusWith = function () {
  7636. if (!this._connectedVirtualKeyboard) {
  7637. return null;
  7638. }
  7639. return [this._connectedVirtualKeyboard];
  7640. };
  7641. /** @hidden */
  7642. InputText.prototype.processKey = function (keyCode, key, evt) {
  7643. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7644. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7645. return;
  7646. }
  7647. //select all
  7648. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7649. this._selectAllText();
  7650. evt.preventDefault();
  7651. return;
  7652. }
  7653. // Specific cases
  7654. switch (keyCode) {
  7655. case 32: //SPACE
  7656. key = " "; //ie11 key for space is "Spacebar"
  7657. break;
  7658. case 191: //SLASH
  7659. if (evt) {
  7660. evt.preventDefault();
  7661. }
  7662. break;
  7663. case 8: // BACKSPACE
  7664. if (this._text && this._text.length > 0) {
  7665. //delete the highlighted text
  7666. if (this._isTextHighlightOn) {
  7667. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7668. this._isTextHighlightOn = false;
  7669. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7670. this._blinkIsEven = false;
  7671. if (evt) {
  7672. evt.preventDefault();
  7673. }
  7674. return;
  7675. }
  7676. //delete single character
  7677. if (this._cursorOffset === 0) {
  7678. this.text = this._text.substr(0, this._text.length - 1);
  7679. }
  7680. else {
  7681. var deletePosition = this._text.length - this._cursorOffset;
  7682. if (deletePosition > 0) {
  7683. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7684. }
  7685. }
  7686. }
  7687. if (evt) {
  7688. evt.preventDefault();
  7689. }
  7690. return;
  7691. case 46: // DELETE
  7692. if (this._isTextHighlightOn) {
  7693. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7694. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7695. while (decrementor > 0 && this._cursorOffset > 0) {
  7696. this._cursorOffset--;
  7697. }
  7698. this._isTextHighlightOn = false;
  7699. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7700. if (evt) {
  7701. evt.preventDefault();
  7702. }
  7703. return;
  7704. }
  7705. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7706. var deletePosition = this._text.length - this._cursorOffset;
  7707. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7708. this._cursorOffset--;
  7709. }
  7710. if (evt) {
  7711. evt.preventDefault();
  7712. }
  7713. return;
  7714. case 13: // RETURN
  7715. this._host.focusedControl = null;
  7716. this._isTextHighlightOn = false;
  7717. return;
  7718. case 35: // END
  7719. this._cursorOffset = 0;
  7720. this._blinkIsEven = false;
  7721. this._isTextHighlightOn = false;
  7722. this._markAsDirty();
  7723. return;
  7724. case 36: // HOME
  7725. this._cursorOffset = this._text.length;
  7726. this._blinkIsEven = false;
  7727. this._isTextHighlightOn = false;
  7728. this._markAsDirty();
  7729. return;
  7730. case 37: // LEFT
  7731. this._cursorOffset++;
  7732. if (this._cursorOffset > this._text.length) {
  7733. this._cursorOffset = this._text.length;
  7734. }
  7735. if (evt && evt.shiftKey) {
  7736. // update the cursor
  7737. this._blinkIsEven = false;
  7738. // shift + ctrl/cmd + <-
  7739. if (evt.ctrlKey || evt.metaKey) {
  7740. if (!this._isTextHighlightOn) {
  7741. if (this._text.length === this._cursorOffset) {
  7742. return;
  7743. }
  7744. else {
  7745. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7746. }
  7747. }
  7748. this._startHighlightIndex = 0;
  7749. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7750. this._cursorOffset = this._text.length;
  7751. this._isTextHighlightOn = true;
  7752. this._markAsDirty();
  7753. return;
  7754. }
  7755. //store the starting point
  7756. if (!this._isTextHighlightOn) {
  7757. this._isTextHighlightOn = true;
  7758. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7759. }
  7760. //if text is already highlighted
  7761. else if (this._cursorIndex === -1) {
  7762. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7763. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7764. }
  7765. //set the highlight indexes
  7766. if (this._cursorIndex < this._cursorOffset) {
  7767. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7768. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7769. }
  7770. else if (this._cursorIndex > this._cursorOffset) {
  7771. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7772. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7773. }
  7774. else {
  7775. this._isTextHighlightOn = false;
  7776. }
  7777. this._markAsDirty();
  7778. return;
  7779. }
  7780. if (this._isTextHighlightOn) {
  7781. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7782. this._isTextHighlightOn = false;
  7783. }
  7784. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7785. this._cursorOffset = this.text.length;
  7786. evt.preventDefault();
  7787. }
  7788. this._blinkIsEven = false;
  7789. this._isTextHighlightOn = false;
  7790. this._cursorIndex = -1;
  7791. this._markAsDirty();
  7792. return;
  7793. case 39: // RIGHT
  7794. this._cursorOffset--;
  7795. if (this._cursorOffset < 0) {
  7796. this._cursorOffset = 0;
  7797. }
  7798. if (evt && evt.shiftKey) {
  7799. //update the cursor
  7800. this._blinkIsEven = false;
  7801. //shift + ctrl/cmd + ->
  7802. if (evt.ctrlKey || evt.metaKey) {
  7803. if (!this._isTextHighlightOn) {
  7804. if (this._cursorOffset === 0) {
  7805. return;
  7806. }
  7807. else {
  7808. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7809. }
  7810. }
  7811. this._endHighlightIndex = this._text.length;
  7812. this._isTextHighlightOn = true;
  7813. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7814. this._cursorOffset = 0;
  7815. this._markAsDirty();
  7816. return;
  7817. }
  7818. if (!this._isTextHighlightOn) {
  7819. this._isTextHighlightOn = true;
  7820. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7821. }
  7822. //if text is already highlighted
  7823. else if (this._cursorIndex === -1) {
  7824. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7825. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7826. }
  7827. //set the highlight indexes
  7828. if (this._cursorIndex < this._cursorOffset) {
  7829. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7830. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7831. }
  7832. else if (this._cursorIndex > this._cursorOffset) {
  7833. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7834. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7835. }
  7836. else {
  7837. this._isTextHighlightOn = false;
  7838. }
  7839. this._markAsDirty();
  7840. return;
  7841. }
  7842. if (this._isTextHighlightOn) {
  7843. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7844. this._isTextHighlightOn = false;
  7845. }
  7846. //ctr + ->
  7847. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7848. this._cursorOffset = 0;
  7849. evt.preventDefault();
  7850. }
  7851. this._blinkIsEven = false;
  7852. this._isTextHighlightOn = false;
  7853. this._cursorIndex = -1;
  7854. this._markAsDirty();
  7855. return;
  7856. case 222: // Dead
  7857. if (evt) {
  7858. evt.preventDefault();
  7859. }
  7860. this._cursorIndex = -1;
  7861. this.deadKey = true;
  7862. break;
  7863. }
  7864. // Printable characters
  7865. if (key &&
  7866. ((keyCode === -1) || // Direct access
  7867. (keyCode === 32) || // Space
  7868. (keyCode > 47 && keyCode < 64) || // Numbers
  7869. (keyCode > 64 && keyCode < 91) || // Letters
  7870. (keyCode > 159 && keyCode < 193) || // Special characters
  7871. (keyCode > 218 && keyCode < 223) || // Special characters
  7872. (keyCode > 95 && keyCode < 112))) { // Numpad
  7873. this._currentKey = key;
  7874. this.onBeforeKeyAddObservable.notifyObservers(this);
  7875. key = this._currentKey;
  7876. if (this._addKey) {
  7877. if (this._isTextHighlightOn) {
  7878. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7879. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7880. this._isTextHighlightOn = false;
  7881. this._blinkIsEven = false;
  7882. this._markAsDirty();
  7883. }
  7884. else if (this._cursorOffset === 0) {
  7885. this.text += key;
  7886. }
  7887. else {
  7888. var insertPosition = this._text.length - this._cursorOffset;
  7889. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7890. }
  7891. }
  7892. }
  7893. };
  7894. /** @hidden */
  7895. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7896. //update the cursor
  7897. this._blinkIsEven = false;
  7898. if (this._cursorIndex === -1) {
  7899. this._cursorIndex = offset;
  7900. }
  7901. else {
  7902. if (this._cursorIndex < this._cursorOffset) {
  7903. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7904. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7905. }
  7906. else if (this._cursorIndex > this._cursorOffset) {
  7907. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7908. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7909. }
  7910. else {
  7911. this._isTextHighlightOn = false;
  7912. this._markAsDirty();
  7913. return;
  7914. }
  7915. }
  7916. this._isTextHighlightOn = true;
  7917. this._markAsDirty();
  7918. };
  7919. /** @hidden */
  7920. InputText.prototype._processDblClick = function (evt) {
  7921. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7922. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7923. this._endHighlightIndex = this._startHighlightIndex;
  7924. var rWord = /\w+/g, moveLeft, moveRight;
  7925. do {
  7926. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7927. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7928. } while (moveLeft || moveRight);
  7929. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7930. this.onTextHighlightObservable.notifyObservers(this);
  7931. this._isTextHighlightOn = true;
  7932. this._clickedCoordinate = null;
  7933. this._blinkIsEven = true;
  7934. this._cursorIndex = -1;
  7935. this._markAsDirty();
  7936. };
  7937. /** @hidden */
  7938. InputText.prototype._selectAllText = function () {
  7939. this._blinkIsEven = true;
  7940. this._isTextHighlightOn = true;
  7941. this._startHighlightIndex = 0;
  7942. this._endHighlightIndex = this._text.length;
  7943. this._cursorOffset = this._text.length;
  7944. this._cursorIndex = -1;
  7945. this._markAsDirty();
  7946. };
  7947. /**
  7948. * Handles the keyboard event
  7949. * @param evt Defines the KeyboardEvent
  7950. */
  7951. InputText.prototype.processKeyboard = function (evt) {
  7952. // process pressed key
  7953. this.processKey(evt.keyCode, evt.key, evt);
  7954. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7955. };
  7956. /** @hidden */
  7957. InputText.prototype._onCopyText = function (ev) {
  7958. this._isTextHighlightOn = false;
  7959. //when write permission to clipbaord data is denied
  7960. try {
  7961. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7962. }
  7963. catch (_a) { } //pass
  7964. this._host.clipboardData = this._highlightedText;
  7965. };
  7966. /** @hidden */
  7967. InputText.prototype._onCutText = function (ev) {
  7968. if (!this._highlightedText) {
  7969. return;
  7970. }
  7971. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7972. this._isTextHighlightOn = false;
  7973. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7974. //when write permission to clipbaord data is denied
  7975. try {
  7976. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7977. }
  7978. catch (_a) { } //pass
  7979. this._host.clipboardData = this._highlightedText;
  7980. this._highlightedText = "";
  7981. };
  7982. /** @hidden */
  7983. InputText.prototype._onPasteText = function (ev) {
  7984. var data = "";
  7985. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7986. data = ev.clipboardData.getData("text/plain");
  7987. }
  7988. else {
  7989. //get the cached data; returns blank string by default
  7990. data = this._host.clipboardData;
  7991. }
  7992. var insertPosition = this._text.length - this._cursorOffset;
  7993. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7994. };
  7995. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7996. var _this = this;
  7997. context.save();
  7998. this._applyStates(context);
  7999. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8000. context.shadowColor = this.shadowColor;
  8001. context.shadowBlur = this.shadowBlur;
  8002. context.shadowOffsetX = this.shadowOffsetX;
  8003. context.shadowOffsetY = this.shadowOffsetY;
  8004. }
  8005. // Background
  8006. if (this._isFocused) {
  8007. if (this._focusedBackground) {
  8008. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8009. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8010. }
  8011. }
  8012. else if (this._background) {
  8013. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8014. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8015. }
  8016. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8017. context.shadowBlur = 0;
  8018. context.shadowOffsetX = 0;
  8019. context.shadowOffsetY = 0;
  8020. }
  8021. if (!this._fontOffset) {
  8022. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8023. }
  8024. // Text
  8025. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8026. if (this.color) {
  8027. context.fillStyle = this.color;
  8028. }
  8029. var text = this._beforeRenderText(this._text);
  8030. if (!this._isFocused && !this._text && this._placeholderText) {
  8031. text = this._placeholderText;
  8032. if (this._placeholderColor) {
  8033. context.fillStyle = this._placeholderColor;
  8034. }
  8035. }
  8036. this._textWidth = context.measureText(text).width;
  8037. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8038. if (this._autoStretchWidth) {
  8039. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8040. }
  8041. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8042. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8043. context.save();
  8044. context.beginPath();
  8045. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8046. context.clip();
  8047. if (this._isFocused && this._textWidth > availableWidth) {
  8048. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8049. if (!this._scrollLeft) {
  8050. this._scrollLeft = textLeft;
  8051. }
  8052. }
  8053. else {
  8054. this._scrollLeft = clipTextLeft;
  8055. }
  8056. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  8057. // Cursor
  8058. if (this._isFocused) {
  8059. // Need to move cursor
  8060. if (this._clickedCoordinate) {
  8061. var rightPosition = this._scrollLeft + this._textWidth;
  8062. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8063. var currentSize = 0;
  8064. this._cursorOffset = 0;
  8065. var previousDist = 0;
  8066. do {
  8067. if (this._cursorOffset) {
  8068. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8069. }
  8070. this._cursorOffset++;
  8071. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8072. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8073. // Find closest move
  8074. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8075. this._cursorOffset--;
  8076. }
  8077. this._blinkIsEven = false;
  8078. this._clickedCoordinate = null;
  8079. }
  8080. // Render cursor
  8081. if (!this._blinkIsEven) {
  8082. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8083. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8084. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8085. if (cursorLeft < clipTextLeft) {
  8086. this._scrollLeft += (clipTextLeft - cursorLeft);
  8087. cursorLeft = clipTextLeft;
  8088. this._markAsDirty();
  8089. }
  8090. else if (cursorLeft > clipTextLeft + availableWidth) {
  8091. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8092. cursorLeft = clipTextLeft + availableWidth;
  8093. this._markAsDirty();
  8094. }
  8095. if (!this._isTextHighlightOn) {
  8096. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8097. }
  8098. }
  8099. clearTimeout(this._blinkTimeout);
  8100. this._blinkTimeout = setTimeout(function () {
  8101. _this._blinkIsEven = !_this._blinkIsEven;
  8102. _this._markAsDirty();
  8103. }, 500);
  8104. //show the highlighted text
  8105. if (this._isTextHighlightOn) {
  8106. clearTimeout(this._blinkTimeout);
  8107. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8108. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8109. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8110. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8111. if (highlightCursorLeft < clipTextLeft) {
  8112. width = width - (clipTextLeft - highlightCursorLeft);
  8113. if (!width) {
  8114. // when using left arrow on text.length > availableWidth;
  8115. // assigns the width of the first letter after clipTextLeft
  8116. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8117. }
  8118. highlightCursorLeft = clipTextLeft;
  8119. }
  8120. //for transparancy
  8121. context.globalAlpha = this._highligherOpacity;
  8122. context.fillStyle = this._textHighlightColor;
  8123. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8124. context.globalAlpha = 1.0;
  8125. }
  8126. }
  8127. context.restore();
  8128. // Border
  8129. if (this._thickness) {
  8130. if (this._isFocused) {
  8131. if (this.focusedColor) {
  8132. context.strokeStyle = this.focusedColor;
  8133. }
  8134. }
  8135. else {
  8136. if (this.color) {
  8137. context.strokeStyle = this.color;
  8138. }
  8139. }
  8140. context.lineWidth = this._thickness;
  8141. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8142. }
  8143. context.restore();
  8144. };
  8145. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8146. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8147. return false;
  8148. }
  8149. this._clickedCoordinate = coordinates.x;
  8150. this._isTextHighlightOn = false;
  8151. this._highlightedText = "";
  8152. this._cursorIndex = -1;
  8153. this._isPointerDown = true;
  8154. this._host._capturingControl[pointerId] = this;
  8155. if (this._host.focusedControl === this) {
  8156. // Move cursor
  8157. clearTimeout(this._blinkTimeout);
  8158. this._markAsDirty();
  8159. return true;
  8160. }
  8161. if (!this._isEnabled) {
  8162. return false;
  8163. }
  8164. this._host.focusedControl = this;
  8165. return true;
  8166. };
  8167. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8168. if (this._host.focusedControl === this && this._isPointerDown) {
  8169. this._clickedCoordinate = coordinates.x;
  8170. this._markAsDirty();
  8171. this._updateValueFromCursorIndex(this._cursorOffset);
  8172. }
  8173. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8174. };
  8175. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8176. this._isPointerDown = false;
  8177. delete this._host._capturingControl[pointerId];
  8178. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8179. };
  8180. InputText.prototype._beforeRenderText = function (text) {
  8181. return text;
  8182. };
  8183. InputText.prototype.dispose = function () {
  8184. _super.prototype.dispose.call(this);
  8185. this.onBlurObservable.clear();
  8186. this.onFocusObservable.clear();
  8187. this.onTextChangedObservable.clear();
  8188. this.onTextCopyObservable.clear();
  8189. this.onTextCutObservable.clear();
  8190. this.onTextPasteObservable.clear();
  8191. this.onTextHighlightObservable.clear();
  8192. this.onKeyboardEventProcessedObservable.clear();
  8193. };
  8194. return InputText;
  8195. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8196. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8197. /***/ }),
  8198. /***/ "./2D/controls/line.ts":
  8199. /*!*****************************!*\
  8200. !*** ./2D/controls/line.ts ***!
  8201. \*****************************/
  8202. /*! exports provided: Line */
  8203. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8204. "use strict";
  8205. __webpack_require__.r(__webpack_exports__);
  8206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8207. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8208. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  8209. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8210. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8211. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8212. /** Class used to render 2D lines */
  8213. var Line = /** @class */ (function (_super) {
  8214. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8215. /**
  8216. * Creates a new Line
  8217. * @param name defines the control name
  8218. */
  8219. function Line(name) {
  8220. var _this = _super.call(this, name) || this;
  8221. _this.name = name;
  8222. _this._lineWidth = 1;
  8223. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8224. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8225. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8226. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8227. _this._dash = new Array();
  8228. _this._automaticSize = true;
  8229. _this.isHitTestVisible = false;
  8230. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8231. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8232. return _this;
  8233. }
  8234. Object.defineProperty(Line.prototype, "dash", {
  8235. /** Gets or sets the dash pattern */
  8236. get: function () {
  8237. return this._dash;
  8238. },
  8239. set: function (value) {
  8240. if (this._dash === value) {
  8241. return;
  8242. }
  8243. this._dash = value;
  8244. this._markAsDirty();
  8245. },
  8246. enumerable: false,
  8247. configurable: true
  8248. });
  8249. Object.defineProperty(Line.prototype, "connectedControl", {
  8250. /** Gets or sets the control connected with the line end */
  8251. get: function () {
  8252. return this._connectedControl;
  8253. },
  8254. set: function (value) {
  8255. var _this = this;
  8256. if (this._connectedControl === value) {
  8257. return;
  8258. }
  8259. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8260. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8261. this._connectedControlDirtyObserver = null;
  8262. }
  8263. if (value) {
  8264. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8265. }
  8266. this._connectedControl = value;
  8267. this._markAsDirty();
  8268. },
  8269. enumerable: false,
  8270. configurable: true
  8271. });
  8272. Object.defineProperty(Line.prototype, "x1", {
  8273. /** Gets or sets start coordinates on X axis */
  8274. get: function () {
  8275. return this._x1.toString(this._host);
  8276. },
  8277. set: function (value) {
  8278. if (this._x1.toString(this._host) === value) {
  8279. return;
  8280. }
  8281. if (this._x1.fromString(value)) {
  8282. this._markAsDirty();
  8283. }
  8284. },
  8285. enumerable: false,
  8286. configurable: true
  8287. });
  8288. Object.defineProperty(Line.prototype, "y1", {
  8289. /** Gets or sets start coordinates on Y axis */
  8290. get: function () {
  8291. return this._y1.toString(this._host);
  8292. },
  8293. set: function (value) {
  8294. if (this._y1.toString(this._host) === value) {
  8295. return;
  8296. }
  8297. if (this._y1.fromString(value)) {
  8298. this._markAsDirty();
  8299. }
  8300. },
  8301. enumerable: false,
  8302. configurable: true
  8303. });
  8304. Object.defineProperty(Line.prototype, "x2", {
  8305. /** Gets or sets end coordinates on X axis */
  8306. get: function () {
  8307. return this._x2.toString(this._host);
  8308. },
  8309. set: function (value) {
  8310. if (this._x2.toString(this._host) === value) {
  8311. return;
  8312. }
  8313. if (this._x2.fromString(value)) {
  8314. this._markAsDirty();
  8315. }
  8316. },
  8317. enumerable: false,
  8318. configurable: true
  8319. });
  8320. Object.defineProperty(Line.prototype, "y2", {
  8321. /** Gets or sets end coordinates on Y axis */
  8322. get: function () {
  8323. return this._y2.toString(this._host);
  8324. },
  8325. set: function (value) {
  8326. if (this._y2.toString(this._host) === value) {
  8327. return;
  8328. }
  8329. if (this._y2.fromString(value)) {
  8330. this._markAsDirty();
  8331. }
  8332. },
  8333. enumerable: false,
  8334. configurable: true
  8335. });
  8336. Object.defineProperty(Line.prototype, "lineWidth", {
  8337. /** Gets or sets line width */
  8338. get: function () {
  8339. return this._lineWidth;
  8340. },
  8341. set: function (value) {
  8342. if (this._lineWidth === value) {
  8343. return;
  8344. }
  8345. this._lineWidth = value;
  8346. this._markAsDirty();
  8347. },
  8348. enumerable: false,
  8349. configurable: true
  8350. });
  8351. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8352. /** Gets or sets horizontal alignment */
  8353. set: function (value) {
  8354. return;
  8355. },
  8356. enumerable: false,
  8357. configurable: true
  8358. });
  8359. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8360. /** Gets or sets vertical alignment */
  8361. set: function (value) {
  8362. return;
  8363. },
  8364. enumerable: false,
  8365. configurable: true
  8366. });
  8367. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8368. get: function () {
  8369. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8370. },
  8371. enumerable: false,
  8372. configurable: true
  8373. });
  8374. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8375. get: function () {
  8376. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8377. },
  8378. enumerable: false,
  8379. configurable: true
  8380. });
  8381. Line.prototype._getTypeName = function () {
  8382. return "Line";
  8383. };
  8384. Line.prototype._draw = function (context) {
  8385. context.save();
  8386. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8387. context.shadowColor = this.shadowColor;
  8388. context.shadowBlur = this.shadowBlur;
  8389. context.shadowOffsetX = this.shadowOffsetX;
  8390. context.shadowOffsetY = this.shadowOffsetY;
  8391. }
  8392. this._applyStates(context);
  8393. context.strokeStyle = this.color;
  8394. context.lineWidth = this._lineWidth;
  8395. context.setLineDash(this._dash);
  8396. context.beginPath();
  8397. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8398. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8399. context.stroke();
  8400. context.restore();
  8401. };
  8402. Line.prototype._measure = function () {
  8403. // Width / Height
  8404. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8405. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8406. };
  8407. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8408. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8409. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8410. };
  8411. /**
  8412. * Move one end of the line given 3D cartesian coordinates.
  8413. * @param position Targeted world position
  8414. * @param scene Scene
  8415. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8416. */
  8417. Line.prototype.moveToVector3 = function (position, scene, end) {
  8418. if (end === void 0) { end = false; }
  8419. if (!this._host || this.parent !== this._host._rootContainer) {
  8420. 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");
  8421. return;
  8422. }
  8423. var globalViewport = this._host._getGlobalViewport(scene);
  8424. 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);
  8425. this._moveToProjectedPosition(projectedPosition, end);
  8426. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8427. this.notRenderable = true;
  8428. return;
  8429. }
  8430. this.notRenderable = false;
  8431. };
  8432. /**
  8433. * Move one end of the line to a position in screen absolute space.
  8434. * @param projectedPosition Position in screen absolute space (X, Y)
  8435. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8436. */
  8437. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8438. if (end === void 0) { end = false; }
  8439. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8440. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8441. if (end) {
  8442. this.x2 = x;
  8443. this.y2 = y;
  8444. this._x2.ignoreAdaptiveScaling = true;
  8445. this._y2.ignoreAdaptiveScaling = true;
  8446. }
  8447. else {
  8448. this.x1 = x;
  8449. this.y1 = y;
  8450. this._x1.ignoreAdaptiveScaling = true;
  8451. this._y1.ignoreAdaptiveScaling = true;
  8452. }
  8453. };
  8454. return Line;
  8455. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8456. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8457. /***/ }),
  8458. /***/ "./2D/controls/multiLine.ts":
  8459. /*!**********************************!*\
  8460. !*** ./2D/controls/multiLine.ts ***!
  8461. \**********************************/
  8462. /*! exports provided: MultiLine */
  8463. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8464. "use strict";
  8465. __webpack_require__.r(__webpack_exports__);
  8466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8467. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8468. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math.vector");
  8469. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8470. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8471. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8472. /**
  8473. * Class used to create multi line control
  8474. */
  8475. var MultiLine = /** @class */ (function (_super) {
  8476. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8477. /**
  8478. * Creates a new MultiLine
  8479. * @param name defines the control name
  8480. */
  8481. function MultiLine(name) {
  8482. var _this = _super.call(this, name) || this;
  8483. _this.name = name;
  8484. _this._lineWidth = 1;
  8485. /** Function called when a point is updated */
  8486. _this.onPointUpdate = function () {
  8487. _this._markAsDirty();
  8488. };
  8489. _this._automaticSize = true;
  8490. _this.isHitTestVisible = false;
  8491. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8492. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8493. _this._dash = [];
  8494. _this._points = [];
  8495. return _this;
  8496. }
  8497. Object.defineProperty(MultiLine.prototype, "dash", {
  8498. /** Gets or sets dash pattern */
  8499. get: function () {
  8500. return this._dash;
  8501. },
  8502. set: function (value) {
  8503. if (this._dash === value) {
  8504. return;
  8505. }
  8506. this._dash = value;
  8507. this._markAsDirty();
  8508. },
  8509. enumerable: false,
  8510. configurable: true
  8511. });
  8512. /**
  8513. * Gets point stored at specified index
  8514. * @param index defines the index to look for
  8515. * @returns the requested point if found
  8516. */
  8517. MultiLine.prototype.getAt = function (index) {
  8518. if (!this._points[index]) {
  8519. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8520. }
  8521. return this._points[index];
  8522. };
  8523. /**
  8524. * Adds new points to the point collection
  8525. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8526. * @returns the list of created MultiLinePoint
  8527. */
  8528. MultiLine.prototype.add = function () {
  8529. var _this = this;
  8530. var items = [];
  8531. for (var _i = 0; _i < arguments.length; _i++) {
  8532. items[_i] = arguments[_i];
  8533. }
  8534. return items.map(function (item) { return _this.push(item); });
  8535. };
  8536. /**
  8537. * Adds a new point to the point collection
  8538. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8539. * @returns the created MultiLinePoint
  8540. */
  8541. MultiLine.prototype.push = function (item) {
  8542. var point = this.getAt(this._points.length);
  8543. if (item == null) {
  8544. return point;
  8545. }
  8546. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8547. point.mesh = item;
  8548. }
  8549. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8550. point.control = item;
  8551. }
  8552. else if (item.x != null && item.y != null) {
  8553. point.x = item.x;
  8554. point.y = item.y;
  8555. }
  8556. return point;
  8557. };
  8558. /**
  8559. * Remove a specific value or point from the active point collection
  8560. * @param value defines the value or point to remove
  8561. */
  8562. MultiLine.prototype.remove = function (value) {
  8563. var index;
  8564. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8565. index = this._points.indexOf(value);
  8566. if (index === -1) {
  8567. return;
  8568. }
  8569. }
  8570. else {
  8571. index = value;
  8572. }
  8573. var point = this._points[index];
  8574. if (!point) {
  8575. return;
  8576. }
  8577. point.dispose();
  8578. this._points.splice(index, 1);
  8579. };
  8580. /**
  8581. * Resets this object to initial state (no point)
  8582. */
  8583. MultiLine.prototype.reset = function () {
  8584. while (this._points.length > 0) {
  8585. this.remove(this._points.length - 1);
  8586. }
  8587. };
  8588. /**
  8589. * Resets all links
  8590. */
  8591. MultiLine.prototype.resetLinks = function () {
  8592. this._points.forEach(function (point) {
  8593. if (point != null) {
  8594. point.resetLinks();
  8595. }
  8596. });
  8597. };
  8598. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8599. /** Gets or sets line width */
  8600. get: function () {
  8601. return this._lineWidth;
  8602. },
  8603. set: function (value) {
  8604. if (this._lineWidth === value) {
  8605. return;
  8606. }
  8607. this._lineWidth = value;
  8608. this._markAsDirty();
  8609. },
  8610. enumerable: false,
  8611. configurable: true
  8612. });
  8613. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8614. set: function (value) {
  8615. return;
  8616. },
  8617. enumerable: false,
  8618. configurable: true
  8619. });
  8620. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8621. set: function (value) {
  8622. return;
  8623. },
  8624. enumerable: false,
  8625. configurable: true
  8626. });
  8627. MultiLine.prototype._getTypeName = function () {
  8628. return "MultiLine";
  8629. };
  8630. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8631. context.save();
  8632. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8633. context.shadowColor = this.shadowColor;
  8634. context.shadowBlur = this.shadowBlur;
  8635. context.shadowOffsetX = this.shadowOffsetX;
  8636. context.shadowOffsetY = this.shadowOffsetY;
  8637. }
  8638. this._applyStates(context);
  8639. context.strokeStyle = this.color;
  8640. context.lineWidth = this._lineWidth;
  8641. context.setLineDash(this._dash);
  8642. context.beginPath();
  8643. var first = true; //first index is not necessarily 0
  8644. this._points.forEach(function (point) {
  8645. if (!point) {
  8646. return;
  8647. }
  8648. if (first) {
  8649. context.moveTo(point._point.x, point._point.y);
  8650. first = false;
  8651. }
  8652. else {
  8653. context.lineTo(point._point.x, point._point.y);
  8654. }
  8655. });
  8656. context.stroke();
  8657. context.restore();
  8658. };
  8659. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8660. var _this = this;
  8661. this._minX = null;
  8662. this._minY = null;
  8663. this._maxX = null;
  8664. this._maxY = null;
  8665. this._points.forEach(function (point, index) {
  8666. if (!point) {
  8667. return;
  8668. }
  8669. point.translate();
  8670. if (_this._minX == null || point._point.x < _this._minX) {
  8671. _this._minX = point._point.x;
  8672. }
  8673. if (_this._minY == null || point._point.y < _this._minY) {
  8674. _this._minY = point._point.y;
  8675. }
  8676. if (_this._maxX == null || point._point.x > _this._maxX) {
  8677. _this._maxX = point._point.x;
  8678. }
  8679. if (_this._maxY == null || point._point.y > _this._maxY) {
  8680. _this._maxY = point._point.y;
  8681. }
  8682. });
  8683. if (this._minX == null) {
  8684. this._minX = 0;
  8685. }
  8686. if (this._minY == null) {
  8687. this._minY = 0;
  8688. }
  8689. if (this._maxX == null) {
  8690. this._maxX = 0;
  8691. }
  8692. if (this._maxY == null) {
  8693. this._maxY = 0;
  8694. }
  8695. };
  8696. MultiLine.prototype._measure = function () {
  8697. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8698. return;
  8699. }
  8700. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8701. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8702. };
  8703. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8704. if (this._minX == null || this._minY == null) {
  8705. return;
  8706. }
  8707. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8708. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8709. };
  8710. MultiLine.prototype.dispose = function () {
  8711. this.reset();
  8712. _super.prototype.dispose.call(this);
  8713. };
  8714. return MultiLine;
  8715. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8716. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8717. /***/ }),
  8718. /***/ "./2D/controls/radioButton.ts":
  8719. /*!************************************!*\
  8720. !*** ./2D/controls/radioButton.ts ***!
  8721. \************************************/
  8722. /*! exports provided: RadioButton */
  8723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8724. "use strict";
  8725. __webpack_require__.r(__webpack_exports__);
  8726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8727. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8728. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  8729. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8730. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8731. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8732. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8733. /**
  8734. * Class used to create radio button controls
  8735. */
  8736. var RadioButton = /** @class */ (function (_super) {
  8737. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8738. /**
  8739. * Creates a new RadioButton
  8740. * @param name defines the control name
  8741. */
  8742. function RadioButton(name) {
  8743. var _this = _super.call(this, name) || this;
  8744. _this.name = name;
  8745. _this._isChecked = false;
  8746. _this._background = "black";
  8747. _this._checkSizeRatio = 0.8;
  8748. _this._thickness = 1;
  8749. /** Gets or sets group name */
  8750. _this.group = "";
  8751. /** Observable raised when isChecked is changed */
  8752. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8753. _this.isPointerBlocker = true;
  8754. return _this;
  8755. }
  8756. Object.defineProperty(RadioButton.prototype, "thickness", {
  8757. /** Gets or sets border thickness */
  8758. get: function () {
  8759. return this._thickness;
  8760. },
  8761. set: function (value) {
  8762. if (this._thickness === value) {
  8763. return;
  8764. }
  8765. this._thickness = value;
  8766. this._markAsDirty();
  8767. },
  8768. enumerable: false,
  8769. configurable: true
  8770. });
  8771. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8772. /** Gets or sets a value indicating the ratio between overall size and check size */
  8773. get: function () {
  8774. return this._checkSizeRatio;
  8775. },
  8776. set: function (value) {
  8777. value = Math.max(Math.min(1, value), 0);
  8778. if (this._checkSizeRatio === value) {
  8779. return;
  8780. }
  8781. this._checkSizeRatio = value;
  8782. this._markAsDirty();
  8783. },
  8784. enumerable: false,
  8785. configurable: true
  8786. });
  8787. Object.defineProperty(RadioButton.prototype, "background", {
  8788. /** Gets or sets background color */
  8789. get: function () {
  8790. return this._background;
  8791. },
  8792. set: function (value) {
  8793. if (this._background === value) {
  8794. return;
  8795. }
  8796. this._background = value;
  8797. this._markAsDirty();
  8798. },
  8799. enumerable: false,
  8800. configurable: true
  8801. });
  8802. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8803. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8804. get: function () {
  8805. return this._isChecked;
  8806. },
  8807. set: function (value) {
  8808. var _this = this;
  8809. if (this._isChecked === value) {
  8810. return;
  8811. }
  8812. this._isChecked = value;
  8813. this._markAsDirty();
  8814. this.onIsCheckedChangedObservable.notifyObservers(value);
  8815. if (this._isChecked && this._host) {
  8816. // Update all controls from same group
  8817. this._host.executeOnAllControls(function (control) {
  8818. if (control === _this) {
  8819. return;
  8820. }
  8821. if (control.group === undefined) {
  8822. return;
  8823. }
  8824. var childRadio = control;
  8825. if (childRadio.group === _this.group) {
  8826. childRadio.isChecked = false;
  8827. }
  8828. });
  8829. }
  8830. },
  8831. enumerable: false,
  8832. configurable: true
  8833. });
  8834. RadioButton.prototype._getTypeName = function () {
  8835. return "RadioButton";
  8836. };
  8837. RadioButton.prototype._draw = function (context) {
  8838. context.save();
  8839. this._applyStates(context);
  8840. var actualWidth = this._currentMeasure.width - this._thickness;
  8841. var actualHeight = this._currentMeasure.height - this._thickness;
  8842. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8843. context.shadowColor = this.shadowColor;
  8844. context.shadowBlur = this.shadowBlur;
  8845. context.shadowOffsetX = this.shadowOffsetX;
  8846. context.shadowOffsetY = this.shadowOffsetY;
  8847. }
  8848. // Outer
  8849. _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);
  8850. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8851. context.fill();
  8852. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8853. context.shadowBlur = 0;
  8854. context.shadowOffsetX = 0;
  8855. context.shadowOffsetY = 0;
  8856. }
  8857. context.strokeStyle = this.color;
  8858. context.lineWidth = this._thickness;
  8859. context.stroke();
  8860. // Inner
  8861. if (this._isChecked) {
  8862. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8863. var offsetWidth = actualWidth * this._checkSizeRatio;
  8864. var offseHeight = actualHeight * this._checkSizeRatio;
  8865. _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);
  8866. context.fill();
  8867. }
  8868. context.restore();
  8869. };
  8870. // Events
  8871. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8872. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8873. return false;
  8874. }
  8875. if (!this.isChecked) {
  8876. this.isChecked = true;
  8877. }
  8878. return true;
  8879. };
  8880. /**
  8881. * Utility function to easily create a radio button with a header
  8882. * @param title defines the label to use for the header
  8883. * @param group defines the group to use for the radio button
  8884. * @param isChecked defines the initial state of the radio button
  8885. * @param onValueChanged defines the callback to call when value changes
  8886. * @returns a StackPanel containing the radio button and a textBlock
  8887. */
  8888. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8889. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8890. panel.isVertical = false;
  8891. panel.height = "30px";
  8892. var radio = new RadioButton();
  8893. radio.width = "20px";
  8894. radio.height = "20px";
  8895. radio.isChecked = isChecked;
  8896. radio.color = "green";
  8897. radio.group = group;
  8898. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8899. panel.addControl(radio);
  8900. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8901. header.text = title;
  8902. header.width = "180px";
  8903. header.paddingLeft = "5px";
  8904. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8905. header.color = "white";
  8906. panel.addControl(header);
  8907. return panel;
  8908. };
  8909. return RadioButton;
  8910. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8911. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8912. /***/ }),
  8913. /***/ "./2D/controls/rectangle.ts":
  8914. /*!**********************************!*\
  8915. !*** ./2D/controls/rectangle.ts ***!
  8916. \**********************************/
  8917. /*! exports provided: Rectangle */
  8918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8919. "use strict";
  8920. __webpack_require__.r(__webpack_exports__);
  8921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8923. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8924. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  8925. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8926. /** Class used to create rectangle container */
  8927. var Rectangle = /** @class */ (function (_super) {
  8928. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8929. /**
  8930. * Creates a new Rectangle
  8931. * @param name defines the control name
  8932. */
  8933. function Rectangle(name) {
  8934. var _this = _super.call(this, name) || this;
  8935. _this.name = name;
  8936. _this._thickness = 1;
  8937. _this._cornerRadius = 0;
  8938. return _this;
  8939. }
  8940. Object.defineProperty(Rectangle.prototype, "thickness", {
  8941. /** Gets or sets border thickness */
  8942. get: function () {
  8943. return this._thickness;
  8944. },
  8945. set: function (value) {
  8946. if (this._thickness === value) {
  8947. return;
  8948. }
  8949. this._thickness = value;
  8950. this._markAsDirty();
  8951. },
  8952. enumerable: false,
  8953. configurable: true
  8954. });
  8955. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8956. /** Gets or sets the corner radius angle */
  8957. get: function () {
  8958. return this._cornerRadius;
  8959. },
  8960. set: function (value) {
  8961. if (value < 0) {
  8962. value = 0;
  8963. }
  8964. if (this._cornerRadius === value) {
  8965. return;
  8966. }
  8967. this._cornerRadius = value;
  8968. this._markAsDirty();
  8969. },
  8970. enumerable: false,
  8971. configurable: true
  8972. });
  8973. Rectangle.prototype._getTypeName = function () {
  8974. return "Rectangle";
  8975. };
  8976. Rectangle.prototype._localDraw = function (context) {
  8977. context.save();
  8978. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8979. context.shadowColor = this.shadowColor;
  8980. context.shadowBlur = this.shadowBlur;
  8981. context.shadowOffsetX = this.shadowOffsetX;
  8982. context.shadowOffsetY = this.shadowOffsetY;
  8983. }
  8984. if (this._background) {
  8985. context.fillStyle = this._background;
  8986. if (this._cornerRadius) {
  8987. this._drawRoundedRect(context, this._thickness / 2);
  8988. context.fill();
  8989. }
  8990. else {
  8991. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8992. }
  8993. }
  8994. if (this._thickness) {
  8995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8996. context.shadowBlur = 0;
  8997. context.shadowOffsetX = 0;
  8998. context.shadowOffsetY = 0;
  8999. }
  9000. if (this.color) {
  9001. context.strokeStyle = this.color;
  9002. }
  9003. context.lineWidth = this._thickness;
  9004. if (this._cornerRadius) {
  9005. this._drawRoundedRect(context, this._thickness / 2);
  9006. context.stroke();
  9007. }
  9008. else {
  9009. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9010. }
  9011. }
  9012. context.restore();
  9013. };
  9014. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9015. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9016. this._measureForChildren.width -= 2 * this._thickness;
  9017. this._measureForChildren.height -= 2 * this._thickness;
  9018. this._measureForChildren.left += this._thickness;
  9019. this._measureForChildren.top += this._thickness;
  9020. };
  9021. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9022. if (offset === void 0) { offset = 0; }
  9023. var x = this._currentMeasure.left + offset;
  9024. var y = this._currentMeasure.top + offset;
  9025. var width = this._currentMeasure.width - offset * 2;
  9026. var height = this._currentMeasure.height - offset * 2;
  9027. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9028. context.beginPath();
  9029. context.moveTo(x + radius, y);
  9030. context.lineTo(x + width - radius, y);
  9031. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9032. context.lineTo(x + width, y + height - radius);
  9033. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9034. context.lineTo(x + radius, y + height);
  9035. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9036. context.lineTo(x, y + radius);
  9037. context.quadraticCurveTo(x, y, x + radius, y);
  9038. context.closePath();
  9039. };
  9040. Rectangle.prototype._clipForChildren = function (context) {
  9041. if (this._cornerRadius) {
  9042. this._drawRoundedRect(context, this._thickness);
  9043. context.clip();
  9044. }
  9045. };
  9046. return Rectangle;
  9047. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9048. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9049. /***/ }),
  9050. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9051. /*!***************************************************!*\
  9052. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9053. \***************************************************/
  9054. /*! exports provided: ScrollViewer */
  9055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9056. "use strict";
  9057. __webpack_require__.r(__webpack_exports__);
  9058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9059. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9060. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9061. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9062. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9063. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9064. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9065. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9066. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  9067. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9068. /**
  9069. * Class used to hold a viewer window and sliders in a grid
  9070. */
  9071. var ScrollViewer = /** @class */ (function (_super) {
  9072. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9073. /**
  9074. * Creates a new ScrollViewer
  9075. * @param name of ScrollViewer
  9076. */
  9077. function ScrollViewer(name, isImageBased) {
  9078. var _this = _super.call(this, name) || this;
  9079. _this._barSize = 20;
  9080. _this._pointerIsOver = false;
  9081. _this._wheelPrecision = 0.05;
  9082. _this._thumbLength = 0.5;
  9083. _this._thumbHeight = 1;
  9084. _this._barImageHeight = 1;
  9085. _this._horizontalBarImageHeight = 1;
  9086. _this._verticalBarImageHeight = 1;
  9087. _this._oldWindowContentsWidth = 0;
  9088. _this._oldWindowContentsHeight = 0;
  9089. _this._forceHorizontalBar = false;
  9090. _this._forceVerticalBar = false;
  9091. _this._useImageBar = isImageBased ? isImageBased : false;
  9092. _this.onDirtyObservable.add(function () {
  9093. _this._horizontalBarSpace.color = _this.color;
  9094. _this._verticalBarSpace.color = _this.color;
  9095. _this._dragSpace.color = _this.color;
  9096. });
  9097. _this.onPointerEnterObservable.add(function () {
  9098. _this._pointerIsOver = true;
  9099. });
  9100. _this.onPointerOutObservable.add(function () {
  9101. _this._pointerIsOver = false;
  9102. });
  9103. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9104. if (_this._useImageBar) {
  9105. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9106. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9107. }
  9108. else {
  9109. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9110. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9111. }
  9112. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9113. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9114. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9115. _this._grid.addColumnDefinition(1);
  9116. _this._grid.addColumnDefinition(0, true);
  9117. _this._grid.addRowDefinition(1);
  9118. _this._grid.addRowDefinition(0, true);
  9119. _super.prototype.addControl.call(_this, _this._grid);
  9120. _this._grid.addControl(_this._window, 0, 0);
  9121. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9122. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9123. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9124. _this._verticalBarSpace.thickness = 1;
  9125. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9126. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9127. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9128. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9129. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9130. _this._horizontalBarSpace.thickness = 1;
  9131. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9132. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9133. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9134. _this._dragSpace.thickness = 1;
  9135. _this._grid.addControl(_this._dragSpace, 1, 1);
  9136. // Colors
  9137. if (!_this._useImageBar) {
  9138. _this.barColor = "grey";
  9139. _this.barBackground = "transparent";
  9140. }
  9141. return _this;
  9142. }
  9143. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9144. /**
  9145. * Gets the horizontal scrollbar
  9146. */
  9147. get: function () {
  9148. return this._horizontalBar;
  9149. },
  9150. enumerable: false,
  9151. configurable: true
  9152. });
  9153. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9154. /**
  9155. * Gets the vertical scrollbar
  9156. */
  9157. get: function () {
  9158. return this._verticalBar;
  9159. },
  9160. enumerable: false,
  9161. configurable: true
  9162. });
  9163. /**
  9164. * Adds a new control to the current container
  9165. * @param control defines the control to add
  9166. * @returns the current container
  9167. */
  9168. ScrollViewer.prototype.addControl = function (control) {
  9169. if (!control) {
  9170. return this;
  9171. }
  9172. this._window.addControl(control);
  9173. return this;
  9174. };
  9175. /**
  9176. * Removes a control from the current container
  9177. * @param control defines the control to remove
  9178. * @returns the current container
  9179. */
  9180. ScrollViewer.prototype.removeControl = function (control) {
  9181. this._window.removeControl(control);
  9182. return this;
  9183. };
  9184. Object.defineProperty(ScrollViewer.prototype, "children", {
  9185. /** Gets the list of children */
  9186. get: function () {
  9187. return this._window.children;
  9188. },
  9189. enumerable: false,
  9190. configurable: true
  9191. });
  9192. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9193. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9194. var child = _a[_i];
  9195. child._markMatrixAsDirty();
  9196. }
  9197. };
  9198. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9199. /**
  9200. * Freezes or unfreezes the controls in the window.
  9201. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9202. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9203. */
  9204. get: function () {
  9205. return this._window.freezeControls;
  9206. },
  9207. set: function (value) {
  9208. this._window.freezeControls = value;
  9209. },
  9210. enumerable: false,
  9211. configurable: true
  9212. });
  9213. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9214. /** Gets the bucket width */
  9215. get: function () {
  9216. return this._window.bucketWidth;
  9217. },
  9218. enumerable: false,
  9219. configurable: true
  9220. });
  9221. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9222. /** Gets the bucket height */
  9223. get: function () {
  9224. return this._window.bucketHeight;
  9225. },
  9226. enumerable: false,
  9227. configurable: true
  9228. });
  9229. /**
  9230. * Sets the bucket sizes.
  9231. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9232. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9233. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9234. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9235. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9236. * used), that's why it is not enabled by default.
  9237. * @param width width of the bucket
  9238. * @param height height of the bucket
  9239. */
  9240. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9241. this._window.setBucketSizes(width, height);
  9242. };
  9243. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9244. /**
  9245. * Forces the horizontal scroll bar to be displayed
  9246. */
  9247. get: function () {
  9248. return this._forceHorizontalBar;
  9249. },
  9250. set: function (value) {
  9251. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9252. this._horizontalBar.isVisible = value;
  9253. this._forceHorizontalBar = value;
  9254. },
  9255. enumerable: false,
  9256. configurable: true
  9257. });
  9258. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9259. /**
  9260. * Forces the vertical scroll bar to be displayed
  9261. */
  9262. get: function () {
  9263. return this._forceVerticalBar;
  9264. },
  9265. set: function (value) {
  9266. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9267. this._verticalBar.isVisible = value;
  9268. this._forceVerticalBar = value;
  9269. },
  9270. enumerable: false,
  9271. configurable: true
  9272. });
  9273. /** Reset the scroll viewer window to initial size */
  9274. ScrollViewer.prototype.resetWindow = function () {
  9275. this._window.width = "100%";
  9276. this._window.height = "100%";
  9277. };
  9278. ScrollViewer.prototype._getTypeName = function () {
  9279. return "ScrollViewer";
  9280. };
  9281. ScrollViewer.prototype._buildClientSizes = function () {
  9282. var ratio = this.host.idealRatio;
  9283. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9284. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9285. this._clientWidth = this._window.parentClientWidth;
  9286. this._clientHeight = this._window.parentClientHeight;
  9287. };
  9288. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9289. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9290. this._buildClientSizes();
  9291. };
  9292. ScrollViewer.prototype._postMeasure = function () {
  9293. _super.prototype._postMeasure.call(this);
  9294. this._updateScroller();
  9295. this._setWindowPosition(false);
  9296. };
  9297. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9298. /**
  9299. * Gets or sets the mouse wheel precision
  9300. * from 0 to 1 with a default value of 0.05
  9301. * */
  9302. get: function () {
  9303. return this._wheelPrecision;
  9304. },
  9305. set: function (value) {
  9306. if (this._wheelPrecision === value) {
  9307. return;
  9308. }
  9309. if (value < 0) {
  9310. value = 0;
  9311. }
  9312. if (value > 1) {
  9313. value = 1;
  9314. }
  9315. this._wheelPrecision = value;
  9316. },
  9317. enumerable: false,
  9318. configurable: true
  9319. });
  9320. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9321. /** Gets or sets the scroll bar container background color */
  9322. get: function () {
  9323. return this._horizontalBarSpace.background;
  9324. },
  9325. set: function (color) {
  9326. if (this._horizontalBarSpace.background === color) {
  9327. return;
  9328. }
  9329. this._horizontalBarSpace.background = color;
  9330. this._verticalBarSpace.background = color;
  9331. },
  9332. enumerable: false,
  9333. configurable: true
  9334. });
  9335. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9336. /** Gets or sets the bar color */
  9337. get: function () {
  9338. return this._barColor;
  9339. },
  9340. set: function (color) {
  9341. if (this._barColor === color) {
  9342. return;
  9343. }
  9344. this._barColor = color;
  9345. this._horizontalBar.color = color;
  9346. this._verticalBar.color = color;
  9347. },
  9348. enumerable: false,
  9349. configurable: true
  9350. });
  9351. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9352. /** Gets or sets the bar image */
  9353. get: function () {
  9354. return this._barImage;
  9355. },
  9356. set: function (value) {
  9357. if (this._barImage === value) {
  9358. return;
  9359. }
  9360. this._barImage = value;
  9361. var hb = this._horizontalBar;
  9362. var vb = this._verticalBar;
  9363. hb.thumbImage = value;
  9364. vb.thumbImage = value;
  9365. },
  9366. enumerable: false,
  9367. configurable: true
  9368. });
  9369. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9370. /** Gets or sets the horizontal bar image */
  9371. get: function () {
  9372. return this._horizontalBarImage;
  9373. },
  9374. set: function (value) {
  9375. if (this._horizontalBarImage === value) {
  9376. return;
  9377. }
  9378. this._horizontalBarImage = value;
  9379. var hb = this._horizontalBar;
  9380. hb.thumbImage = value;
  9381. },
  9382. enumerable: false,
  9383. configurable: true
  9384. });
  9385. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9386. /** Gets or sets the vertical bar image */
  9387. get: function () {
  9388. return this._verticalBarImage;
  9389. },
  9390. set: function (value) {
  9391. if (this._verticalBarImage === value) {
  9392. return;
  9393. }
  9394. this._verticalBarImage = value;
  9395. var vb = this._verticalBar;
  9396. vb.thumbImage = value;
  9397. },
  9398. enumerable: false,
  9399. configurable: true
  9400. });
  9401. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9402. /** Gets or sets the size of the bar */
  9403. get: function () {
  9404. return this._barSize;
  9405. },
  9406. set: function (value) {
  9407. if (this._barSize === value) {
  9408. return;
  9409. }
  9410. this._barSize = value;
  9411. this._markAsDirty();
  9412. if (this._horizontalBar.isVisible) {
  9413. this._grid.setRowDefinition(1, this._barSize, true);
  9414. }
  9415. if (this._verticalBar.isVisible) {
  9416. this._grid.setColumnDefinition(1, this._barSize, true);
  9417. }
  9418. },
  9419. enumerable: false,
  9420. configurable: true
  9421. });
  9422. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9423. /** Gets or sets the length of the thumb */
  9424. get: function () {
  9425. return this._thumbLength;
  9426. },
  9427. set: function (value) {
  9428. if (this._thumbLength === value) {
  9429. return;
  9430. }
  9431. if (value <= 0) {
  9432. value = 0.1;
  9433. }
  9434. if (value > 1) {
  9435. value = 1;
  9436. }
  9437. this._thumbLength = value;
  9438. var hb = this._horizontalBar;
  9439. var vb = this._verticalBar;
  9440. hb.thumbLength = value;
  9441. vb.thumbLength = value;
  9442. this._markAsDirty();
  9443. },
  9444. enumerable: false,
  9445. configurable: true
  9446. });
  9447. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9448. /** Gets or sets the height of the thumb */
  9449. get: function () {
  9450. return this._thumbHeight;
  9451. },
  9452. set: function (value) {
  9453. if (this._thumbHeight === value) {
  9454. return;
  9455. }
  9456. if (value <= 0) {
  9457. value = 0.1;
  9458. }
  9459. if (value > 1) {
  9460. value = 1;
  9461. }
  9462. this._thumbHeight = value;
  9463. var hb = this._horizontalBar;
  9464. var vb = this._verticalBar;
  9465. hb.thumbHeight = value;
  9466. vb.thumbHeight = value;
  9467. this._markAsDirty();
  9468. },
  9469. enumerable: false,
  9470. configurable: true
  9471. });
  9472. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9473. /** Gets or sets the height of the bar image */
  9474. get: function () {
  9475. return this._barImageHeight;
  9476. },
  9477. set: function (value) {
  9478. if (this._barImageHeight === value) {
  9479. return;
  9480. }
  9481. if (value <= 0) {
  9482. value = 0.1;
  9483. }
  9484. if (value > 1) {
  9485. value = 1;
  9486. }
  9487. this._barImageHeight = value;
  9488. var hb = this._horizontalBar;
  9489. var vb = this._verticalBar;
  9490. hb.barImageHeight = value;
  9491. vb.barImageHeight = value;
  9492. this._markAsDirty();
  9493. },
  9494. enumerable: false,
  9495. configurable: true
  9496. });
  9497. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9498. /** Gets or sets the height of the horizontal bar image */
  9499. get: function () {
  9500. return this._horizontalBarImageHeight;
  9501. },
  9502. set: function (value) {
  9503. if (this._horizontalBarImageHeight === value) {
  9504. return;
  9505. }
  9506. if (value <= 0) {
  9507. value = 0.1;
  9508. }
  9509. if (value > 1) {
  9510. value = 1;
  9511. }
  9512. this._horizontalBarImageHeight = value;
  9513. var hb = this._horizontalBar;
  9514. hb.barImageHeight = value;
  9515. this._markAsDirty();
  9516. },
  9517. enumerable: false,
  9518. configurable: true
  9519. });
  9520. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9521. /** Gets or sets the height of the vertical bar image */
  9522. get: function () {
  9523. return this._verticalBarImageHeight;
  9524. },
  9525. set: function (value) {
  9526. if (this._verticalBarImageHeight === value) {
  9527. return;
  9528. }
  9529. if (value <= 0) {
  9530. value = 0.1;
  9531. }
  9532. if (value > 1) {
  9533. value = 1;
  9534. }
  9535. this._verticalBarImageHeight = value;
  9536. var vb = this._verticalBar;
  9537. vb.barImageHeight = value;
  9538. this._markAsDirty();
  9539. },
  9540. enumerable: false,
  9541. configurable: true
  9542. });
  9543. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9544. /** Gets or sets the bar background */
  9545. get: function () {
  9546. return this._barBackground;
  9547. },
  9548. set: function (color) {
  9549. if (this._barBackground === color) {
  9550. return;
  9551. }
  9552. this._barBackground = color;
  9553. var hb = this._horizontalBar;
  9554. var vb = this._verticalBar;
  9555. hb.background = color;
  9556. vb.background = color;
  9557. this._dragSpace.background = color;
  9558. },
  9559. enumerable: false,
  9560. configurable: true
  9561. });
  9562. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9563. /** Gets or sets the bar background image */
  9564. get: function () {
  9565. return this._barBackgroundImage;
  9566. },
  9567. set: function (value) {
  9568. if (this._barBackgroundImage === value) {
  9569. }
  9570. this._barBackgroundImage = value;
  9571. var hb = this._horizontalBar;
  9572. var vb = this._verticalBar;
  9573. hb.backgroundImage = value;
  9574. vb.backgroundImage = value;
  9575. },
  9576. enumerable: false,
  9577. configurable: true
  9578. });
  9579. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9580. /** Gets or sets the horizontal bar background image */
  9581. get: function () {
  9582. return this._horizontalBarBackgroundImage;
  9583. },
  9584. set: function (value) {
  9585. if (this._horizontalBarBackgroundImage === value) {
  9586. }
  9587. this._horizontalBarBackgroundImage = value;
  9588. var hb = this._horizontalBar;
  9589. hb.backgroundImage = value;
  9590. },
  9591. enumerable: false,
  9592. configurable: true
  9593. });
  9594. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9595. /** Gets or sets the vertical bar background image */
  9596. get: function () {
  9597. return this._verticalBarBackgroundImage;
  9598. },
  9599. set: function (value) {
  9600. if (this._verticalBarBackgroundImage === value) {
  9601. }
  9602. this._verticalBarBackgroundImage = value;
  9603. var vb = this._verticalBar;
  9604. vb.backgroundImage = value;
  9605. },
  9606. enumerable: false,
  9607. configurable: true
  9608. });
  9609. ScrollViewer.prototype._setWindowPosition = function (force) {
  9610. if (force === void 0) { force = true; }
  9611. var ratio = this.host.idealRatio;
  9612. var windowContentsWidth = this._window._currentMeasure.width;
  9613. var windowContentsHeight = this._window._currentMeasure.height;
  9614. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9615. return;
  9616. }
  9617. this._oldWindowContentsWidth = windowContentsWidth;
  9618. this._oldWindowContentsHeight = windowContentsHeight;
  9619. var _endLeft = this._clientWidth - windowContentsWidth;
  9620. var _endTop = this._clientHeight - windowContentsHeight;
  9621. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9622. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9623. if (newLeft !== this._window.left) {
  9624. this._window.left = newLeft;
  9625. if (!this.freezeControls) {
  9626. this._rebuildLayout = true;
  9627. }
  9628. }
  9629. if (newTop !== this._window.top) {
  9630. this._window.top = newTop;
  9631. if (!this.freezeControls) {
  9632. this._rebuildLayout = true;
  9633. }
  9634. }
  9635. };
  9636. /** @hidden */
  9637. ScrollViewer.prototype._updateScroller = function () {
  9638. var windowContentsWidth = this._window._currentMeasure.width;
  9639. var windowContentsHeight = this._window._currentMeasure.height;
  9640. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9641. this._grid.setRowDefinition(1, 0, true);
  9642. this._horizontalBar.isVisible = false;
  9643. this._horizontalBar.value = 0;
  9644. this._rebuildLayout = true;
  9645. }
  9646. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9647. this._grid.setRowDefinition(1, this._barSize, true);
  9648. this._horizontalBar.isVisible = true;
  9649. this._rebuildLayout = true;
  9650. }
  9651. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9652. this._grid.setColumnDefinition(1, 0, true);
  9653. this._verticalBar.isVisible = false;
  9654. this._verticalBar.value = 0;
  9655. this._rebuildLayout = true;
  9656. }
  9657. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9658. this._grid.setColumnDefinition(1, this._barSize, true);
  9659. this._verticalBar.isVisible = true;
  9660. this._rebuildLayout = true;
  9661. }
  9662. this._buildClientSizes();
  9663. var ratio = this.host.idealRatio;
  9664. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9665. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9666. };
  9667. ScrollViewer.prototype._link = function (host) {
  9668. _super.prototype._link.call(this, host);
  9669. this._attachWheel();
  9670. };
  9671. /** @hidden */
  9672. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9673. var _this = this;
  9674. barControl.paddingLeft = 0;
  9675. barControl.width = "100%";
  9676. barControl.height = "100%";
  9677. barControl.barOffset = 0;
  9678. barControl.value = 0;
  9679. barControl.maximum = 1;
  9680. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9681. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9682. barControl.isVertical = isVertical;
  9683. barControl.rotation = rotation;
  9684. barControl.isVisible = false;
  9685. barContainer.addControl(barControl);
  9686. barControl.onValueChangedObservable.add(function (value) {
  9687. _this._setWindowPosition();
  9688. });
  9689. };
  9690. /** @hidden */
  9691. ScrollViewer.prototype._attachWheel = function () {
  9692. var _this = this;
  9693. if (!this._host || this._onWheelObserver) {
  9694. return;
  9695. }
  9696. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9697. if (!_this._pointerIsOver) {
  9698. return;
  9699. }
  9700. if (_this._verticalBar.isVisible == true) {
  9701. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9702. _this._verticalBar.value -= _this._wheelPrecision;
  9703. }
  9704. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9705. _this._verticalBar.value += _this._wheelPrecision;
  9706. }
  9707. }
  9708. if (_this._horizontalBar.isVisible == true) {
  9709. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9710. _this._horizontalBar.value += _this._wheelPrecision;
  9711. }
  9712. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9713. _this._horizontalBar.value -= _this._wheelPrecision;
  9714. }
  9715. }
  9716. });
  9717. };
  9718. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9719. if (!this.isHighlighted) {
  9720. return;
  9721. }
  9722. _super.prototype._renderHighlightSpecific.call(this, context);
  9723. this._grid._renderHighlightSpecific(context);
  9724. context.restore();
  9725. };
  9726. /** Releases associated resources */
  9727. ScrollViewer.prototype.dispose = function () {
  9728. this.onWheelObservable.remove(this._onWheelObserver);
  9729. this._onWheelObserver = null;
  9730. _super.prototype.dispose.call(this);
  9731. };
  9732. return ScrollViewer;
  9733. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9734. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9735. /***/ }),
  9736. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9737. /*!*********************************************************!*\
  9738. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9739. \*********************************************************/
  9740. /*! exports provided: _ScrollViewerWindow */
  9741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9742. "use strict";
  9743. __webpack_require__.r(__webpack_exports__);
  9744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9745. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9746. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9747. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9748. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9749. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9750. /**
  9751. * Class used to hold a the container for ScrollViewer
  9752. * @hidden
  9753. */
  9754. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9755. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9756. /**
  9757. * Creates a new ScrollViewerWindow
  9758. * @param name of ScrollViewerWindow
  9759. */
  9760. function _ScrollViewerWindow(name) {
  9761. var _this = _super.call(this, name) || this;
  9762. _this._freezeControls = false;
  9763. _this._bucketWidth = 0;
  9764. _this._bucketHeight = 0;
  9765. _this._buckets = {};
  9766. return _this;
  9767. }
  9768. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9769. get: function () {
  9770. return this._freezeControls;
  9771. },
  9772. set: function (value) {
  9773. if (this._freezeControls === value) {
  9774. return;
  9775. }
  9776. if (!value) {
  9777. this._restoreMeasures();
  9778. }
  9779. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9780. this._freezeControls = false;
  9781. var textureSize = this.host.getSize();
  9782. var renderWidth = textureSize.width;
  9783. var renderHeight = textureSize.height;
  9784. var context = this.host.getContext();
  9785. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9786. this.host._numLayoutCalls = 0;
  9787. this.host._rootContainer._layout(measure, context);
  9788. // in freeze mode, prepare children measures accordingly
  9789. if (value) {
  9790. this._updateMeasures();
  9791. if (this._useBuckets()) {
  9792. this._makeBuckets();
  9793. }
  9794. }
  9795. this._freezeControls = value;
  9796. this.host.markAsDirty(); // redraw with the (new) current settings
  9797. },
  9798. enumerable: false,
  9799. configurable: true
  9800. });
  9801. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9802. get: function () {
  9803. return this._bucketWidth;
  9804. },
  9805. enumerable: false,
  9806. configurable: true
  9807. });
  9808. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9809. get: function () {
  9810. return this._bucketHeight;
  9811. },
  9812. enumerable: false,
  9813. configurable: true
  9814. });
  9815. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9816. this._bucketWidth = width;
  9817. this._bucketHeight = height;
  9818. if (this._useBuckets()) {
  9819. if (this._freezeControls) {
  9820. this._makeBuckets();
  9821. }
  9822. }
  9823. else {
  9824. this._buckets = {};
  9825. }
  9826. };
  9827. _ScrollViewerWindow.prototype._useBuckets = function () {
  9828. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9829. };
  9830. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9831. this._buckets = {};
  9832. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9833. this._dispatchInBuckets(this._children);
  9834. this._oldLeft = null;
  9835. this._oldTop = null;
  9836. };
  9837. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9838. for (var i = 0; i < children.length; ++i) {
  9839. var child = children[i];
  9840. 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);
  9841. while (bStartY <= bEndY) {
  9842. for (var x = bStartX; x <= bEndX; ++x) {
  9843. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9844. if (!lstc) {
  9845. lstc = [];
  9846. this._buckets[bucket] = lstc;
  9847. }
  9848. lstc.push(child);
  9849. }
  9850. bStartY++;
  9851. }
  9852. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9853. this._dispatchInBuckets(child._children);
  9854. }
  9855. }
  9856. };
  9857. // reset left and top measures for the window and all its children
  9858. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9859. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9860. this._measureForChildren.left -= left;
  9861. this._measureForChildren.top -= top;
  9862. this._currentMeasure.left -= left;
  9863. this._currentMeasure.top -= top;
  9864. this._customData.origLeftForChildren = this._measureForChildren.left;
  9865. this._customData.origTopForChildren = this._measureForChildren.top;
  9866. this._customData.origLeft = this._currentMeasure.left;
  9867. this._customData.origTop = this._currentMeasure.top;
  9868. this._updateChildrenMeasures(this._children, left, top);
  9869. };
  9870. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9871. for (var i = 0; i < children.length; ++i) {
  9872. var child = children[i];
  9873. child._currentMeasure.left -= left;
  9874. child._currentMeasure.top -= top;
  9875. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9876. child._customData._origTop = child._currentMeasure.top;
  9877. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9878. this._updateChildrenMeasures(child._children, left, top);
  9879. }
  9880. }
  9881. };
  9882. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  9883. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9884. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  9885. this._measureForChildren.top = this._customData.origTopForChildren + top;
  9886. this._currentMeasure.left = this._customData.origLeft + left;
  9887. this._currentMeasure.top = this._customData.origTop + top;
  9888. };
  9889. _ScrollViewerWindow.prototype._getTypeName = function () {
  9890. return "ScrollViewerWindow";
  9891. };
  9892. /** @hidden */
  9893. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9894. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9895. this._parentMeasure = parentMeasure;
  9896. this._measureForChildren.left = this._currentMeasure.left;
  9897. this._measureForChildren.top = this._currentMeasure.top;
  9898. this._measureForChildren.width = parentMeasure.width;
  9899. this._measureForChildren.height = parentMeasure.height;
  9900. };
  9901. /** @hidden */
  9902. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9903. if (this._freezeControls) {
  9904. this.invalidateRect(); // will trigger a redraw of the window
  9905. return false;
  9906. }
  9907. return _super.prototype._layout.call(this, parentMeasure, context);
  9908. };
  9909. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9910. for (var i = 0; i < children.length; ++i) {
  9911. var child = children[i];
  9912. child._currentMeasure.left = child._customData._origLeft + left;
  9913. child._currentMeasure.top = child._customData._origTop + top;
  9914. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9915. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9916. this._scrollChildren(child._children, left, top);
  9917. }
  9918. }
  9919. };
  9920. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9921. 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);
  9922. while (bStartY <= bEndY) {
  9923. for (var x = bStartX; x <= bEndX; ++x) {
  9924. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9925. if (lstc) {
  9926. for (var i = 0; i < lstc.length; ++i) {
  9927. var child = lstc[i];
  9928. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9929. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9930. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9931. }
  9932. }
  9933. }
  9934. bStartY++;
  9935. }
  9936. };
  9937. /** @hidden */
  9938. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9939. if (!this._freezeControls) {
  9940. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9941. return;
  9942. }
  9943. this._localDraw(context);
  9944. if (this.clipChildren) {
  9945. this._clipForChildren(context);
  9946. }
  9947. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9948. if (this._useBuckets()) {
  9949. if (this._oldLeft !== null && this._oldTop !== null) {
  9950. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9951. this._scrollChildrenWithBuckets(left, top, left, top);
  9952. }
  9953. else {
  9954. this._scrollChildren(this._children, left, top);
  9955. }
  9956. }
  9957. else {
  9958. this._scrollChildren(this._children, left, top);
  9959. }
  9960. this._oldLeft = left;
  9961. this._oldTop = top;
  9962. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9963. var child = _a[_i];
  9964. if (!child._intersectsRect(this._parentMeasure)) {
  9965. continue;
  9966. }
  9967. child._render(context, this._parentMeasure);
  9968. }
  9969. };
  9970. _ScrollViewerWindow.prototype._postMeasure = function () {
  9971. if (this._freezeControls) {
  9972. _super.prototype._postMeasure.call(this);
  9973. return;
  9974. }
  9975. var maxWidth = this.parentClientWidth;
  9976. var maxHeight = this.parentClientHeight;
  9977. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9978. var child = _a[_i];
  9979. if (!child.isVisible || child.notRenderable) {
  9980. continue;
  9981. }
  9982. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9983. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9984. }
  9985. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9986. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9987. }
  9988. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9989. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9990. }
  9991. if (this._currentMeasure.width !== maxWidth) {
  9992. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9993. this._currentMeasure.width = maxWidth;
  9994. this._rebuildLayout = true;
  9995. this._isDirty = true;
  9996. }
  9997. if (this._currentMeasure.height !== maxHeight) {
  9998. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9999. this._currentMeasure.height = maxHeight;
  10000. this._rebuildLayout = true;
  10001. this._isDirty = true;
  10002. }
  10003. _super.prototype._postMeasure.call(this);
  10004. };
  10005. return _ScrollViewerWindow;
  10006. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10007. /***/ }),
  10008. /***/ "./2D/controls/selector.ts":
  10009. /*!*********************************!*\
  10010. !*** ./2D/controls/selector.ts ***!
  10011. \*********************************/
  10012. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10014. "use strict";
  10015. __webpack_require__.r(__webpack_exports__);
  10016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10021. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10022. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10023. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10024. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10025. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10026. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10027. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10028. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10029. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10030. /** Class used to create a RadioGroup
  10031. * which contains groups of radio buttons
  10032. */
  10033. var SelectorGroup = /** @class */ (function () {
  10034. /**
  10035. * Creates a new SelectorGroup
  10036. * @param name of group, used as a group heading
  10037. */
  10038. function SelectorGroup(
  10039. /** name of SelectorGroup */
  10040. name) {
  10041. this.name = name;
  10042. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10043. this._selectors = new Array();
  10044. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10045. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10046. this._groupHeader = this._addGroupHeader(name);
  10047. }
  10048. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10049. /** Gets the groupPanel of the SelectorGroup */
  10050. get: function () {
  10051. return this._groupPanel;
  10052. },
  10053. enumerable: false,
  10054. configurable: true
  10055. });
  10056. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10057. /** Gets the selectors array */
  10058. get: function () {
  10059. return this._selectors;
  10060. },
  10061. enumerable: false,
  10062. configurable: true
  10063. });
  10064. Object.defineProperty(SelectorGroup.prototype, "header", {
  10065. /** Gets and sets the group header */
  10066. get: function () {
  10067. return this._groupHeader.text;
  10068. },
  10069. set: function (label) {
  10070. if (this._groupHeader.text === "label") {
  10071. return;
  10072. }
  10073. this._groupHeader.text = label;
  10074. },
  10075. enumerable: false,
  10076. configurable: true
  10077. });
  10078. /** @hidden */
  10079. SelectorGroup.prototype._addGroupHeader = function (text) {
  10080. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10081. groupHeading.width = 0.9;
  10082. groupHeading.height = "30px";
  10083. groupHeading.textWrapping = true;
  10084. groupHeading.color = "black";
  10085. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10086. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10087. groupHeading.left = "2px";
  10088. this._groupPanel.addControl(groupHeading);
  10089. return groupHeading;
  10090. };
  10091. /** @hidden*/
  10092. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10093. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10094. return;
  10095. }
  10096. return this._selectors[selectorNb];
  10097. };
  10098. /** Removes the selector at the given position
  10099. * @param selectorNb the position of the selector within the group
  10100. */
  10101. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10102. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10103. return;
  10104. }
  10105. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10106. this._selectors.splice(selectorNb, 1);
  10107. };
  10108. return SelectorGroup;
  10109. }());
  10110. /** Class used to create a CheckboxGroup
  10111. * which contains groups of checkbox buttons
  10112. */
  10113. var CheckboxGroup = /** @class */ (function (_super) {
  10114. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10115. function CheckboxGroup() {
  10116. return _super !== null && _super.apply(this, arguments) || this;
  10117. }
  10118. /** Adds a checkbox as a control
  10119. * @param text is the label for the selector
  10120. * @param func is the function called when the Selector is checked
  10121. * @param checked is true when Selector is checked
  10122. */
  10123. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10124. if (func === void 0) { func = function (s) { }; }
  10125. if (checked === void 0) { checked = false; }
  10126. var checked = checked || false;
  10127. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10128. button.width = "20px";
  10129. button.height = "20px";
  10130. button.color = "#364249";
  10131. button.background = "#CCCCCC";
  10132. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10133. button.onIsCheckedChangedObservable.add(function (state) {
  10134. func(state);
  10135. });
  10136. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10137. _selector.height = "30px";
  10138. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10139. _selector.left = "4px";
  10140. this.groupPanel.addControl(_selector);
  10141. this.selectors.push(_selector);
  10142. button.isChecked = checked;
  10143. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10144. button.color = this.groupPanel.parent.parent.buttonColor;
  10145. button.background = this.groupPanel.parent.parent.buttonBackground;
  10146. }
  10147. };
  10148. /** @hidden */
  10149. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10150. this.selectors[selectorNb].children[1].text = label;
  10151. };
  10152. /** @hidden */
  10153. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10154. this.selectors[selectorNb].children[1].color = color;
  10155. };
  10156. /** @hidden */
  10157. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10158. this.selectors[selectorNb].children[0].color = color;
  10159. };
  10160. /** @hidden */
  10161. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10162. this.selectors[selectorNb].children[0].background = color;
  10163. };
  10164. return CheckboxGroup;
  10165. }(SelectorGroup));
  10166. /** Class used to create a RadioGroup
  10167. * which contains groups of radio buttons
  10168. */
  10169. var RadioGroup = /** @class */ (function (_super) {
  10170. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10171. function RadioGroup() {
  10172. var _this = _super !== null && _super.apply(this, arguments) || this;
  10173. _this._selectNb = 0;
  10174. return _this;
  10175. }
  10176. /** Adds a radio button as a control
  10177. * @param label is the label for the selector
  10178. * @param func is the function called when the Selector is checked
  10179. * @param checked is true when Selector is checked
  10180. */
  10181. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10182. if (func === void 0) { func = function (n) { }; }
  10183. if (checked === void 0) { checked = false; }
  10184. var nb = this._selectNb++;
  10185. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10186. button.name = label;
  10187. button.width = "20px";
  10188. button.height = "20px";
  10189. button.color = "#364249";
  10190. button.background = "#CCCCCC";
  10191. button.group = this.name;
  10192. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10193. button.onIsCheckedChangedObservable.add(function (state) {
  10194. if (state) {
  10195. func(nb);
  10196. }
  10197. });
  10198. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10199. _selector.height = "30px";
  10200. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10201. _selector.left = "4px";
  10202. this.groupPanel.addControl(_selector);
  10203. this.selectors.push(_selector);
  10204. button.isChecked = checked;
  10205. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10206. button.color = this.groupPanel.parent.parent.buttonColor;
  10207. button.background = this.groupPanel.parent.parent.buttonBackground;
  10208. }
  10209. };
  10210. /** @hidden */
  10211. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10212. this.selectors[selectorNb].children[1].text = label;
  10213. };
  10214. /** @hidden */
  10215. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10216. this.selectors[selectorNb].children[1].color = color;
  10217. };
  10218. /** @hidden */
  10219. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10220. this.selectors[selectorNb].children[0].color = color;
  10221. };
  10222. /** @hidden */
  10223. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10224. this.selectors[selectorNb].children[0].background = color;
  10225. };
  10226. return RadioGroup;
  10227. }(SelectorGroup));
  10228. /** Class used to create a SliderGroup
  10229. * which contains groups of slider buttons
  10230. */
  10231. var SliderGroup = /** @class */ (function (_super) {
  10232. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10233. function SliderGroup() {
  10234. return _super !== null && _super.apply(this, arguments) || this;
  10235. }
  10236. /**
  10237. * Adds a slider to the SelectorGroup
  10238. * @param label is the label for the SliderBar
  10239. * @param func is the function called when the Slider moves
  10240. * @param unit is a string describing the units used, eg degrees or metres
  10241. * @param min is the minimum value for the Slider
  10242. * @param max is the maximum value for the Slider
  10243. * @param value is the start value for the Slider between min and max
  10244. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10245. */
  10246. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10247. if (func === void 0) { func = function (v) { }; }
  10248. if (unit === void 0) { unit = "Units"; }
  10249. if (min === void 0) { min = 0; }
  10250. if (max === void 0) { max = 0; }
  10251. if (value === void 0) { value = 0; }
  10252. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10253. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10254. button.name = unit;
  10255. button.value = value;
  10256. button.minimum = min;
  10257. button.maximum = max;
  10258. button.width = 0.9;
  10259. button.height = "20px";
  10260. button.color = "#364249";
  10261. button.background = "#CCCCCC";
  10262. button.borderColor = "black";
  10263. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10264. button.left = "4px";
  10265. button.paddingBottom = "4px";
  10266. button.onValueChangedObservable.add(function (value) {
  10267. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10268. func(value);
  10269. });
  10270. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10271. _selector.height = "60px";
  10272. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10273. _selector.left = "4px";
  10274. _selector.children[0].name = label;
  10275. this.groupPanel.addControl(_selector);
  10276. this.selectors.push(_selector);
  10277. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10278. button.color = this.groupPanel.parent.parent.buttonColor;
  10279. button.background = this.groupPanel.parent.parent.buttonBackground;
  10280. }
  10281. };
  10282. /** @hidden */
  10283. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10284. this.selectors[selectorNb].children[0].name = label;
  10285. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10286. };
  10287. /** @hidden */
  10288. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10289. this.selectors[selectorNb].children[0].color = color;
  10290. };
  10291. /** @hidden */
  10292. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10293. this.selectors[selectorNb].children[1].color = color;
  10294. };
  10295. /** @hidden */
  10296. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10297. this.selectors[selectorNb].children[1].background = color;
  10298. };
  10299. return SliderGroup;
  10300. }(SelectorGroup));
  10301. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10302. * @see https://doc.babylonjs.com/how_to/selector
  10303. */
  10304. var SelectionPanel = /** @class */ (function (_super) {
  10305. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10306. /**
  10307. * Creates a new SelectionPanel
  10308. * @param name of SelectionPanel
  10309. * @param groups is an array of SelectionGroups
  10310. */
  10311. function SelectionPanel(
  10312. /** name of SelectionPanel */
  10313. name,
  10314. /** an array of SelectionGroups */
  10315. groups) {
  10316. if (groups === void 0) { groups = []; }
  10317. var _this = _super.call(this, name) || this;
  10318. _this.name = name;
  10319. _this.groups = groups;
  10320. _this._buttonColor = "#364249";
  10321. _this._buttonBackground = "#CCCCCC";
  10322. _this._headerColor = "black";
  10323. _this._barColor = "white";
  10324. _this._barHeight = "2px";
  10325. _this._spacerHeight = "20px";
  10326. _this._bars = new Array();
  10327. _this._groups = groups;
  10328. _this.thickness = 2;
  10329. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10330. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10331. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10332. _this._panel.top = 5;
  10333. _this._panel.left = 5;
  10334. _this._panel.width = 0.95;
  10335. if (groups.length > 0) {
  10336. for (var i = 0; i < groups.length - 1; i++) {
  10337. _this._panel.addControl(groups[i].groupPanel);
  10338. _this._addSpacer();
  10339. }
  10340. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10341. }
  10342. _this.addControl(_this._panel);
  10343. return _this;
  10344. }
  10345. SelectionPanel.prototype._getTypeName = function () {
  10346. return "SelectionPanel";
  10347. };
  10348. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10349. /** Gets or sets the headerColor */
  10350. get: function () {
  10351. return this._headerColor;
  10352. },
  10353. set: function (color) {
  10354. if (this._headerColor === color) {
  10355. return;
  10356. }
  10357. this._headerColor = color;
  10358. this._setHeaderColor();
  10359. },
  10360. enumerable: false,
  10361. configurable: true
  10362. });
  10363. SelectionPanel.prototype._setHeaderColor = function () {
  10364. for (var i = 0; i < this._groups.length; i++) {
  10365. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10366. }
  10367. };
  10368. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10369. /** Gets or sets the button color */
  10370. get: function () {
  10371. return this._buttonColor;
  10372. },
  10373. set: function (color) {
  10374. if (this._buttonColor === color) {
  10375. return;
  10376. }
  10377. this._buttonColor = color;
  10378. this._setbuttonColor();
  10379. },
  10380. enumerable: false,
  10381. configurable: true
  10382. });
  10383. SelectionPanel.prototype._setbuttonColor = function () {
  10384. for (var i = 0; i < this._groups.length; i++) {
  10385. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10386. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10387. }
  10388. }
  10389. };
  10390. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10391. /** Gets or sets the label color */
  10392. get: function () {
  10393. return this._labelColor;
  10394. },
  10395. set: function (color) {
  10396. if (this._labelColor === color) {
  10397. return;
  10398. }
  10399. this._labelColor = color;
  10400. this._setLabelColor();
  10401. },
  10402. enumerable: false,
  10403. configurable: true
  10404. });
  10405. SelectionPanel.prototype._setLabelColor = function () {
  10406. for (var i = 0; i < this._groups.length; i++) {
  10407. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10408. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10409. }
  10410. }
  10411. };
  10412. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10413. /** Gets or sets the button background */
  10414. get: function () {
  10415. return this._buttonBackground;
  10416. },
  10417. set: function (color) {
  10418. if (this._buttonBackground === color) {
  10419. return;
  10420. }
  10421. this._buttonBackground = color;
  10422. this._setButtonBackground();
  10423. },
  10424. enumerable: false,
  10425. configurable: true
  10426. });
  10427. SelectionPanel.prototype._setButtonBackground = function () {
  10428. for (var i = 0; i < this._groups.length; i++) {
  10429. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10430. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10431. }
  10432. }
  10433. };
  10434. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10435. /** Gets or sets the color of separator bar */
  10436. get: function () {
  10437. return this._barColor;
  10438. },
  10439. set: function (color) {
  10440. if (this._barColor === color) {
  10441. return;
  10442. }
  10443. this._barColor = color;
  10444. this._setBarColor();
  10445. },
  10446. enumerable: false,
  10447. configurable: true
  10448. });
  10449. SelectionPanel.prototype._setBarColor = function () {
  10450. for (var i = 0; i < this._bars.length; i++) {
  10451. this._bars[i].children[0].background = this._barColor;
  10452. }
  10453. };
  10454. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10455. /** Gets or sets the height of separator bar */
  10456. get: function () {
  10457. return this._barHeight;
  10458. },
  10459. set: function (value) {
  10460. if (this._barHeight === value) {
  10461. return;
  10462. }
  10463. this._barHeight = value;
  10464. this._setBarHeight();
  10465. },
  10466. enumerable: false,
  10467. configurable: true
  10468. });
  10469. SelectionPanel.prototype._setBarHeight = function () {
  10470. for (var i = 0; i < this._bars.length; i++) {
  10471. this._bars[i].children[0].height = this._barHeight;
  10472. }
  10473. };
  10474. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10475. /** Gets or sets the height of spacers*/
  10476. get: function () {
  10477. return this._spacerHeight;
  10478. },
  10479. set: function (value) {
  10480. if (this._spacerHeight === value) {
  10481. return;
  10482. }
  10483. this._spacerHeight = value;
  10484. this._setSpacerHeight();
  10485. },
  10486. enumerable: false,
  10487. configurable: true
  10488. });
  10489. SelectionPanel.prototype._setSpacerHeight = function () {
  10490. for (var i = 0; i < this._bars.length; i++) {
  10491. this._bars[i].height = this._spacerHeight;
  10492. }
  10493. };
  10494. /** Adds a bar between groups */
  10495. SelectionPanel.prototype._addSpacer = function () {
  10496. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10497. separator.width = 1;
  10498. separator.height = this._spacerHeight;
  10499. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10500. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10501. bar.width = 1;
  10502. bar.height = this._barHeight;
  10503. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10504. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10505. bar.background = this._barColor;
  10506. bar.color = "transparent";
  10507. separator.addControl(bar);
  10508. this._panel.addControl(separator);
  10509. this._bars.push(separator);
  10510. };
  10511. /** Add a group to the selection panel
  10512. * @param group is the selector group to add
  10513. */
  10514. SelectionPanel.prototype.addGroup = function (group) {
  10515. if (this._groups.length > 0) {
  10516. this._addSpacer();
  10517. }
  10518. this._panel.addControl(group.groupPanel);
  10519. this._groups.push(group);
  10520. group.groupPanel.children[0].color = this._headerColor;
  10521. for (var j = 0; j < group.selectors.length; j++) {
  10522. group._setSelectorButtonColor(j, this._buttonColor);
  10523. group._setSelectorButtonBackground(j, this._buttonBackground);
  10524. }
  10525. };
  10526. /** Remove the group from the given position
  10527. * @param groupNb is the position of the group in the list
  10528. */
  10529. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10530. if (groupNb < 0 || groupNb >= this._groups.length) {
  10531. return;
  10532. }
  10533. var group = this._groups[groupNb];
  10534. this._panel.removeControl(group.groupPanel);
  10535. this._groups.splice(groupNb, 1);
  10536. if (groupNb < this._bars.length) {
  10537. this._panel.removeControl(this._bars[groupNb]);
  10538. this._bars.splice(groupNb, 1);
  10539. }
  10540. };
  10541. /** Change a group header label
  10542. * @param label is the new group header label
  10543. * @param groupNb is the number of the group to relabel
  10544. * */
  10545. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10546. if (groupNb < 0 || groupNb >= this._groups.length) {
  10547. return;
  10548. }
  10549. var group = this._groups[groupNb];
  10550. group.groupPanel.children[0].text = label;
  10551. };
  10552. /** Change selector label to the one given
  10553. * @param label is the new selector label
  10554. * @param groupNb is the number of the groupcontaining the selector
  10555. * @param selectorNb is the number of the selector within a group to relabel
  10556. * */
  10557. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10558. if (groupNb < 0 || groupNb >= this._groups.length) {
  10559. return;
  10560. }
  10561. var group = this._groups[groupNb];
  10562. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10563. return;
  10564. }
  10565. group._setSelectorLabel(selectorNb, label);
  10566. };
  10567. /** For a given group position remove the selector at the given position
  10568. * @param groupNb is the number of the group to remove the selector from
  10569. * @param selectorNb is the number of the selector within the group
  10570. */
  10571. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10572. if (groupNb < 0 || groupNb >= this._groups.length) {
  10573. return;
  10574. }
  10575. var group = this._groups[groupNb];
  10576. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10577. return;
  10578. }
  10579. group.removeSelector(selectorNb);
  10580. };
  10581. /** For a given group position of correct type add a checkbox button
  10582. * @param groupNb is the number of the group to remove the selector from
  10583. * @param label is the label for the selector
  10584. * @param func is the function called when the Selector is checked
  10585. * @param checked is true when Selector is checked
  10586. */
  10587. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10588. if (func === void 0) { func = function () { }; }
  10589. if (checked === void 0) { checked = false; }
  10590. if (groupNb < 0 || groupNb >= this._groups.length) {
  10591. return;
  10592. }
  10593. var group = this._groups[groupNb];
  10594. group.addCheckbox(label, func, checked);
  10595. };
  10596. /** For a given group position of correct type add a radio button
  10597. * @param groupNb is the number of the group to remove the selector from
  10598. * @param label is the label for the selector
  10599. * @param func is the function called when the Selector is checked
  10600. * @param checked is true when Selector is checked
  10601. */
  10602. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10603. if (func === void 0) { func = function () { }; }
  10604. if (checked === void 0) { checked = false; }
  10605. if (groupNb < 0 || groupNb >= this._groups.length) {
  10606. return;
  10607. }
  10608. var group = this._groups[groupNb];
  10609. group.addRadio(label, func, checked);
  10610. };
  10611. /**
  10612. * For a given slider group add a slider
  10613. * @param groupNb is the number of the group to add the slider to
  10614. * @param label is the label for the Slider
  10615. * @param func is the function called when the Slider moves
  10616. * @param unit is a string describing the units used, eg degrees or metres
  10617. * @param min is the minimum value for the Slider
  10618. * @param max is the maximum value for the Slider
  10619. * @param value is the start value for the Slider between min and max
  10620. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10621. */
  10622. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10623. if (func === void 0) { func = function () { }; }
  10624. if (unit === void 0) { unit = "Units"; }
  10625. if (min === void 0) { min = 0; }
  10626. if (max === void 0) { max = 0; }
  10627. if (value === void 0) { value = 0; }
  10628. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10629. if (groupNb < 0 || groupNb >= this._groups.length) {
  10630. return;
  10631. }
  10632. var group = this._groups[groupNb];
  10633. group.addSlider(label, func, unit, min, max, value, onVal);
  10634. };
  10635. return SelectionPanel;
  10636. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10637. /***/ }),
  10638. /***/ "./2D/controls/sliders/baseSlider.ts":
  10639. /*!*******************************************!*\
  10640. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10641. \*******************************************/
  10642. /*! exports provided: BaseSlider */
  10643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10644. "use strict";
  10645. __webpack_require__.r(__webpack_exports__);
  10646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10647. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10648. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  10649. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10650. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10651. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10652. /**
  10653. * Class used to create slider controls
  10654. */
  10655. var BaseSlider = /** @class */ (function (_super) {
  10656. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10657. /**
  10658. * Creates a new BaseSlider
  10659. * @param name defines the control name
  10660. */
  10661. function BaseSlider(name) {
  10662. var _this = _super.call(this, name) || this;
  10663. _this.name = name;
  10664. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10665. _this._minimum = 0;
  10666. _this._maximum = 100;
  10667. _this._value = 50;
  10668. _this._isVertical = false;
  10669. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10670. _this._isThumbClamped = false;
  10671. _this._displayThumb = true;
  10672. _this._step = 0;
  10673. _this._lastPointerDownID = -1;
  10674. // Shared rendering info
  10675. _this._effectiveBarOffset = 0;
  10676. /** Observable raised when the sldier value changes */
  10677. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10678. // Events
  10679. _this._pointerIsDown = false;
  10680. _this.isPointerBlocker = true;
  10681. return _this;
  10682. }
  10683. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10684. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10685. get: function () {
  10686. return this._displayThumb;
  10687. },
  10688. set: function (value) {
  10689. if (this._displayThumb === value) {
  10690. return;
  10691. }
  10692. this._displayThumb = value;
  10693. this._markAsDirty();
  10694. },
  10695. enumerable: false,
  10696. configurable: true
  10697. });
  10698. Object.defineProperty(BaseSlider.prototype, "step", {
  10699. /** Gets or sets a step to apply to values (0 by default) */
  10700. get: function () {
  10701. return this._step;
  10702. },
  10703. set: function (value) {
  10704. if (this._step === value) {
  10705. return;
  10706. }
  10707. this._step = value;
  10708. this._markAsDirty();
  10709. },
  10710. enumerable: false,
  10711. configurable: true
  10712. });
  10713. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10714. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10715. get: function () {
  10716. return this._barOffset.toString(this._host);
  10717. },
  10718. set: function (value) {
  10719. if (this._barOffset.toString(this._host) === value) {
  10720. return;
  10721. }
  10722. if (this._barOffset.fromString(value)) {
  10723. this._markAsDirty();
  10724. }
  10725. },
  10726. enumerable: false,
  10727. configurable: true
  10728. });
  10729. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10730. /** Gets main bar offset in pixels*/
  10731. get: function () {
  10732. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10733. },
  10734. enumerable: false,
  10735. configurable: true
  10736. });
  10737. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10738. /** Gets or sets thumb width */
  10739. get: function () {
  10740. return this._thumbWidth.toString(this._host);
  10741. },
  10742. set: function (value) {
  10743. if (this._thumbWidth.toString(this._host) === value) {
  10744. return;
  10745. }
  10746. if (this._thumbWidth.fromString(value)) {
  10747. this._markAsDirty();
  10748. }
  10749. },
  10750. enumerable: false,
  10751. configurable: true
  10752. });
  10753. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10754. /** Gets thumb width in pixels */
  10755. get: function () {
  10756. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10757. },
  10758. enumerable: false,
  10759. configurable: true
  10760. });
  10761. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10762. /** Gets or sets minimum value */
  10763. get: function () {
  10764. return this._minimum;
  10765. },
  10766. set: function (value) {
  10767. if (this._minimum === value) {
  10768. return;
  10769. }
  10770. this._minimum = value;
  10771. this._markAsDirty();
  10772. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10773. },
  10774. enumerable: false,
  10775. configurable: true
  10776. });
  10777. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10778. /** Gets or sets maximum value */
  10779. get: function () {
  10780. return this._maximum;
  10781. },
  10782. set: function (value) {
  10783. if (this._maximum === value) {
  10784. return;
  10785. }
  10786. this._maximum = value;
  10787. this._markAsDirty();
  10788. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10789. },
  10790. enumerable: false,
  10791. configurable: true
  10792. });
  10793. Object.defineProperty(BaseSlider.prototype, "value", {
  10794. /** Gets or sets current value */
  10795. get: function () {
  10796. return this._value;
  10797. },
  10798. set: function (value) {
  10799. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10800. if (this._value === value) {
  10801. return;
  10802. }
  10803. this._value = value;
  10804. this._markAsDirty();
  10805. this.onValueChangedObservable.notifyObservers(this._value);
  10806. },
  10807. enumerable: false,
  10808. configurable: true
  10809. });
  10810. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10811. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10812. get: function () {
  10813. return this._isVertical;
  10814. },
  10815. set: function (value) {
  10816. if (this._isVertical === value) {
  10817. return;
  10818. }
  10819. this._isVertical = value;
  10820. this._markAsDirty();
  10821. },
  10822. enumerable: false,
  10823. configurable: true
  10824. });
  10825. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10826. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10827. get: function () {
  10828. return this._isThumbClamped;
  10829. },
  10830. set: function (value) {
  10831. if (this._isThumbClamped === value) {
  10832. return;
  10833. }
  10834. this._isThumbClamped = value;
  10835. this._markAsDirty();
  10836. },
  10837. enumerable: false,
  10838. configurable: true
  10839. });
  10840. BaseSlider.prototype._getTypeName = function () {
  10841. return "BaseSlider";
  10842. };
  10843. BaseSlider.prototype._getThumbPosition = function () {
  10844. if (this.isVertical) {
  10845. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10846. }
  10847. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10848. };
  10849. BaseSlider.prototype._getThumbThickness = function (type) {
  10850. var thumbThickness = 0;
  10851. switch (type) {
  10852. case "circle":
  10853. if (this._thumbWidth.isPixel) {
  10854. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10855. }
  10856. else {
  10857. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10858. }
  10859. break;
  10860. case "rectangle":
  10861. if (this._thumbWidth.isPixel) {
  10862. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10863. }
  10864. else {
  10865. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10866. }
  10867. }
  10868. return thumbThickness;
  10869. };
  10870. BaseSlider.prototype._prepareRenderingData = function (type) {
  10871. // Main bar
  10872. this._effectiveBarOffset = 0;
  10873. this._renderLeft = this._currentMeasure.left;
  10874. this._renderTop = this._currentMeasure.top;
  10875. this._renderWidth = this._currentMeasure.width;
  10876. this._renderHeight = this._currentMeasure.height;
  10877. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10878. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10879. this._effectiveThumbThickness = this._getThumbThickness(type);
  10880. if (this.displayThumb) {
  10881. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10882. }
  10883. //throw error when height is less than width for vertical slider
  10884. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10885. console.error("Height should be greater than width");
  10886. return;
  10887. }
  10888. if (this._barOffset.isPixel) {
  10889. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10890. }
  10891. else {
  10892. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10893. }
  10894. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10895. if (this.isVertical) {
  10896. this._renderLeft += this._effectiveBarOffset;
  10897. if (!this.isThumbClamped && this.displayThumb) {
  10898. this._renderTop += (this._effectiveThumbThickness / 2);
  10899. }
  10900. this._renderHeight = this._backgroundBoxLength;
  10901. this._renderWidth = this._backgroundBoxThickness;
  10902. }
  10903. else {
  10904. this._renderTop += this._effectiveBarOffset;
  10905. if (!this.isThumbClamped && this.displayThumb) {
  10906. this._renderLeft += (this._effectiveThumbThickness / 2);
  10907. }
  10908. this._renderHeight = this._backgroundBoxThickness;
  10909. this._renderWidth = this._backgroundBoxLength;
  10910. }
  10911. };
  10912. /** @hidden */
  10913. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10914. if (this.rotation != 0) {
  10915. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10916. x = this._transformedPosition.x;
  10917. y = this._transformedPosition.y;
  10918. }
  10919. var value;
  10920. if (this._isVertical) {
  10921. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10922. }
  10923. else {
  10924. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10925. }
  10926. var mult = (1 / this._step) | 0;
  10927. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10928. };
  10929. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10930. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10931. return false;
  10932. }
  10933. this._pointerIsDown = true;
  10934. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10935. this._host._capturingControl[pointerId] = this;
  10936. this._lastPointerDownID = pointerId;
  10937. return true;
  10938. };
  10939. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10940. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10941. if (pointerId != this._lastPointerDownID) {
  10942. return;
  10943. }
  10944. if (this._pointerIsDown) {
  10945. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10946. }
  10947. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10948. };
  10949. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10950. this._pointerIsDown = false;
  10951. delete this._host._capturingControl[pointerId];
  10952. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10953. };
  10954. return BaseSlider;
  10955. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10956. /***/ }),
  10957. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10958. /*!*************************************************!*\
  10959. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10960. \*************************************************/
  10961. /*! exports provided: ImageBasedSlider */
  10962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10963. "use strict";
  10964. __webpack_require__.r(__webpack_exports__);
  10965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10966. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10967. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10968. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10969. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  10970. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10971. /**
  10972. * Class used to create slider controls based on images
  10973. */
  10974. var ImageBasedSlider = /** @class */ (function (_super) {
  10975. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10976. /**
  10977. * Creates a new ImageBasedSlider
  10978. * @param name defines the control name
  10979. */
  10980. function ImageBasedSlider(name) {
  10981. var _this = _super.call(this, name) || this;
  10982. _this.name = name;
  10983. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10984. return _this;
  10985. }
  10986. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10987. get: function () {
  10988. return this._displayThumb && this.thumbImage != null;
  10989. },
  10990. set: function (value) {
  10991. if (this._displayThumb === value) {
  10992. return;
  10993. }
  10994. this._displayThumb = value;
  10995. this._markAsDirty();
  10996. },
  10997. enumerable: false,
  10998. configurable: true
  10999. });
  11000. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11001. /**
  11002. * Gets or sets the image used to render the background
  11003. */
  11004. get: function () {
  11005. return this._backgroundImage;
  11006. },
  11007. set: function (value) {
  11008. var _this = this;
  11009. if (this._backgroundImage === value) {
  11010. return;
  11011. }
  11012. this._backgroundImage = value;
  11013. if (value && !value.isLoaded) {
  11014. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11015. }
  11016. this._markAsDirty();
  11017. },
  11018. enumerable: false,
  11019. configurable: true
  11020. });
  11021. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11022. /**
  11023. * Gets or sets the image used to render the value bar
  11024. */
  11025. get: function () {
  11026. return this._valueBarImage;
  11027. },
  11028. set: function (value) {
  11029. var _this = this;
  11030. if (this._valueBarImage === value) {
  11031. return;
  11032. }
  11033. this._valueBarImage = value;
  11034. if (value && !value.isLoaded) {
  11035. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11036. }
  11037. this._markAsDirty();
  11038. },
  11039. enumerable: false,
  11040. configurable: true
  11041. });
  11042. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11043. /**
  11044. * Gets or sets the image used to render the thumb
  11045. */
  11046. get: function () {
  11047. return this._thumbImage;
  11048. },
  11049. set: function (value) {
  11050. var _this = this;
  11051. if (this._thumbImage === value) {
  11052. return;
  11053. }
  11054. this._thumbImage = value;
  11055. if (value && !value.isLoaded) {
  11056. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11057. }
  11058. this._markAsDirty();
  11059. },
  11060. enumerable: false,
  11061. configurable: true
  11062. });
  11063. ImageBasedSlider.prototype._getTypeName = function () {
  11064. return "ImageBasedSlider";
  11065. };
  11066. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11067. context.save();
  11068. this._applyStates(context);
  11069. this._prepareRenderingData("rectangle");
  11070. var thumbPosition = this._getThumbPosition();
  11071. var left = this._renderLeft;
  11072. var top = this._renderTop;
  11073. var width = this._renderWidth;
  11074. var height = this._renderHeight;
  11075. // Background
  11076. if (this._backgroundImage) {
  11077. this._tempMeasure.copyFromFloats(left, top, width, height);
  11078. if (this.isThumbClamped && this.displayThumb) {
  11079. if (this.isVertical) {
  11080. this._tempMeasure.height += this._effectiveThumbThickness;
  11081. }
  11082. else {
  11083. this._tempMeasure.width += this._effectiveThumbThickness;
  11084. }
  11085. }
  11086. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11087. this._backgroundImage._draw(context);
  11088. }
  11089. // Bar
  11090. if (this._valueBarImage) {
  11091. if (this.isVertical) {
  11092. if (this.isThumbClamped && this.displayThumb) {
  11093. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11094. }
  11095. else {
  11096. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11097. }
  11098. }
  11099. else {
  11100. if (this.isThumbClamped && this.displayThumb) {
  11101. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11102. }
  11103. else {
  11104. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11105. }
  11106. }
  11107. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11108. this._valueBarImage._draw(context);
  11109. }
  11110. // Thumb
  11111. if (this.displayThumb) {
  11112. if (this.isVertical) {
  11113. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11114. }
  11115. else {
  11116. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11117. }
  11118. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11119. this._thumbImage._draw(context);
  11120. }
  11121. context.restore();
  11122. };
  11123. return ImageBasedSlider;
  11124. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11125. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11126. /***/ }),
  11127. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11128. /*!***********************************************!*\
  11129. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11130. \***********************************************/
  11131. /*! exports provided: ImageScrollBar */
  11132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11133. "use strict";
  11134. __webpack_require__.r(__webpack_exports__);
  11135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11137. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11138. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11139. /**
  11140. * Class used to create slider controls
  11141. */
  11142. var ImageScrollBar = /** @class */ (function (_super) {
  11143. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11144. /**
  11145. * Creates a new ImageScrollBar
  11146. * @param name defines the control name
  11147. */
  11148. function ImageScrollBar(name) {
  11149. var _this = _super.call(this, name) || this;
  11150. _this.name = name;
  11151. _this._thumbLength = 0.5;
  11152. _this._thumbHeight = 1;
  11153. _this._barImageHeight = 1;
  11154. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11155. /** Number of 90° rotation to apply on the images when in vertical mode */
  11156. _this.num90RotationInVerticalMode = 1;
  11157. return _this;
  11158. }
  11159. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11160. /**
  11161. * Gets or sets the image used to render the background for horizontal bar
  11162. */
  11163. get: function () {
  11164. return this._backgroundBaseImage;
  11165. },
  11166. set: function (value) {
  11167. var _this = this;
  11168. if (this._backgroundBaseImage === value) {
  11169. return;
  11170. }
  11171. this._backgroundBaseImage = value;
  11172. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11173. if (!value.isLoaded) {
  11174. value.onImageLoadedObservable.addOnce(function () {
  11175. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11176. _this._backgroundImage = rotatedValue;
  11177. if (!rotatedValue.isLoaded) {
  11178. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11179. _this._markAsDirty();
  11180. });
  11181. }
  11182. _this._markAsDirty();
  11183. });
  11184. }
  11185. else {
  11186. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11187. this._markAsDirty();
  11188. }
  11189. }
  11190. else {
  11191. this._backgroundImage = value;
  11192. if (value && !value.isLoaded) {
  11193. value.onImageLoadedObservable.addOnce(function () {
  11194. _this._markAsDirty();
  11195. });
  11196. }
  11197. this._markAsDirty();
  11198. }
  11199. },
  11200. enumerable: false,
  11201. configurable: true
  11202. });
  11203. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11204. /**
  11205. * Gets or sets the image used to render the thumb
  11206. */
  11207. get: function () {
  11208. return this._thumbBaseImage;
  11209. },
  11210. set: function (value) {
  11211. var _this = this;
  11212. if (this._thumbBaseImage === value) {
  11213. return;
  11214. }
  11215. this._thumbBaseImage = value;
  11216. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11217. if (!value.isLoaded) {
  11218. value.onImageLoadedObservable.addOnce(function () {
  11219. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11220. _this._thumbImage = rotatedValue;
  11221. if (!rotatedValue.isLoaded) {
  11222. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11223. _this._markAsDirty();
  11224. });
  11225. }
  11226. _this._markAsDirty();
  11227. });
  11228. }
  11229. else {
  11230. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11231. this._markAsDirty();
  11232. }
  11233. }
  11234. else {
  11235. this._thumbImage = value;
  11236. if (value && !value.isLoaded) {
  11237. value.onImageLoadedObservable.addOnce(function () {
  11238. _this._markAsDirty();
  11239. });
  11240. }
  11241. this._markAsDirty();
  11242. }
  11243. },
  11244. enumerable: false,
  11245. configurable: true
  11246. });
  11247. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11248. /**
  11249. * Gets or sets the length of the thumb
  11250. */
  11251. get: function () {
  11252. return this._thumbLength;
  11253. },
  11254. set: function (value) {
  11255. if (this._thumbLength === value) {
  11256. return;
  11257. }
  11258. this._thumbLength = value;
  11259. this._markAsDirty();
  11260. },
  11261. enumerable: false,
  11262. configurable: true
  11263. });
  11264. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11265. /**
  11266. * Gets or sets the height of the thumb
  11267. */
  11268. get: function () {
  11269. return this._thumbHeight;
  11270. },
  11271. set: function (value) {
  11272. if (this._thumbLength === value) {
  11273. return;
  11274. }
  11275. this._thumbHeight = value;
  11276. this._markAsDirty();
  11277. },
  11278. enumerable: false,
  11279. configurable: true
  11280. });
  11281. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11282. /**
  11283. * Gets or sets the height of the bar image
  11284. */
  11285. get: function () {
  11286. return this._barImageHeight;
  11287. },
  11288. set: function (value) {
  11289. if (this._barImageHeight === value) {
  11290. return;
  11291. }
  11292. this._barImageHeight = value;
  11293. this._markAsDirty();
  11294. },
  11295. enumerable: false,
  11296. configurable: true
  11297. });
  11298. ImageScrollBar.prototype._getTypeName = function () {
  11299. return "ImageScrollBar";
  11300. };
  11301. ImageScrollBar.prototype._getThumbThickness = function () {
  11302. var thumbThickness = 0;
  11303. if (this._thumbWidth.isPixel) {
  11304. thumbThickness = this._thumbWidth.getValue(this._host);
  11305. }
  11306. else {
  11307. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11308. }
  11309. return thumbThickness;
  11310. };
  11311. ImageScrollBar.prototype._draw = function (context) {
  11312. context.save();
  11313. this._applyStates(context);
  11314. this._prepareRenderingData("rectangle");
  11315. var thumbPosition = this._getThumbPosition();
  11316. var left = this._renderLeft;
  11317. var top = this._renderTop;
  11318. var width = this._renderWidth;
  11319. var height = this._renderHeight;
  11320. // Background
  11321. if (this._backgroundImage) {
  11322. this._tempMeasure.copyFromFloats(left, top, width, height);
  11323. if (this.isVertical) {
  11324. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11325. this._tempMeasure.height += this._effectiveThumbThickness;
  11326. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11327. }
  11328. else {
  11329. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11330. this._tempMeasure.width += this._effectiveThumbThickness;
  11331. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11332. }
  11333. this._backgroundImage._draw(context);
  11334. }
  11335. // Thumb
  11336. if (this.isVertical) {
  11337. 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);
  11338. }
  11339. else {
  11340. 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);
  11341. }
  11342. if (this._thumbImage) {
  11343. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11344. this._thumbImage._draw(context);
  11345. }
  11346. context.restore();
  11347. };
  11348. /** @hidden */
  11349. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11350. if (this.rotation != 0) {
  11351. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11352. x = this._transformedPosition.x;
  11353. y = this._transformedPosition.y;
  11354. }
  11355. if (this._first) {
  11356. this._first = false;
  11357. this._originX = x;
  11358. this._originY = y;
  11359. // Check if move is required
  11360. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11361. if (this.isVertical) {
  11362. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11363. }
  11364. else {
  11365. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11366. }
  11367. }
  11368. }
  11369. // Delta mode
  11370. var delta = 0;
  11371. if (this.isVertical) {
  11372. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11373. }
  11374. else {
  11375. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11376. }
  11377. this.value += delta * (this.maximum - this.minimum);
  11378. this._originX = x;
  11379. this._originY = y;
  11380. };
  11381. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11382. this._first = true;
  11383. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11384. };
  11385. return ImageScrollBar;
  11386. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11387. /***/ }),
  11388. /***/ "./2D/controls/sliders/scrollBar.ts":
  11389. /*!******************************************!*\
  11390. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11391. \******************************************/
  11392. /*! exports provided: ScrollBar */
  11393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11394. "use strict";
  11395. __webpack_require__.r(__webpack_exports__);
  11396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11397. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11398. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11399. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11400. /**
  11401. * Class used to create slider controls
  11402. */
  11403. var ScrollBar = /** @class */ (function (_super) {
  11404. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11405. /**
  11406. * Creates a new Slider
  11407. * @param name defines the control name
  11408. */
  11409. function ScrollBar(name) {
  11410. var _this = _super.call(this, name) || this;
  11411. _this.name = name;
  11412. _this._background = "black";
  11413. _this._borderColor = "white";
  11414. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11415. return _this;
  11416. }
  11417. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11418. /** Gets or sets border color */
  11419. get: function () {
  11420. return this._borderColor;
  11421. },
  11422. set: function (value) {
  11423. if (this._borderColor === value) {
  11424. return;
  11425. }
  11426. this._borderColor = value;
  11427. this._markAsDirty();
  11428. },
  11429. enumerable: false,
  11430. configurable: true
  11431. });
  11432. Object.defineProperty(ScrollBar.prototype, "background", {
  11433. /** Gets or sets background color */
  11434. get: function () {
  11435. return this._background;
  11436. },
  11437. set: function (value) {
  11438. if (this._background === value) {
  11439. return;
  11440. }
  11441. this._background = value;
  11442. this._markAsDirty();
  11443. },
  11444. enumerable: false,
  11445. configurable: true
  11446. });
  11447. ScrollBar.prototype._getTypeName = function () {
  11448. return "Scrollbar";
  11449. };
  11450. ScrollBar.prototype._getThumbThickness = function () {
  11451. var thumbThickness = 0;
  11452. if (this._thumbWidth.isPixel) {
  11453. thumbThickness = this._thumbWidth.getValue(this._host);
  11454. }
  11455. else {
  11456. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11457. }
  11458. return thumbThickness;
  11459. };
  11460. ScrollBar.prototype._draw = function (context) {
  11461. context.save();
  11462. this._applyStates(context);
  11463. this._prepareRenderingData("rectangle");
  11464. var left = this._renderLeft;
  11465. var thumbPosition = this._getThumbPosition();
  11466. context.fillStyle = this._background;
  11467. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11468. // Value bar
  11469. context.fillStyle = this.color;
  11470. // Thumb
  11471. if (this.isVertical) {
  11472. this._tempMeasure.left = left - this._effectiveBarOffset;
  11473. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11474. this._tempMeasure.width = this._currentMeasure.width;
  11475. this._tempMeasure.height = this._effectiveThumbThickness;
  11476. }
  11477. else {
  11478. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11479. this._tempMeasure.top = this._currentMeasure.top;
  11480. this._tempMeasure.width = this._effectiveThumbThickness;
  11481. this._tempMeasure.height = this._currentMeasure.height;
  11482. }
  11483. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11484. context.restore();
  11485. };
  11486. /** @hidden */
  11487. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11488. if (this.rotation != 0) {
  11489. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11490. x = this._transformedPosition.x;
  11491. y = this._transformedPosition.y;
  11492. }
  11493. if (this._first) {
  11494. this._first = false;
  11495. this._originX = x;
  11496. this._originY = y;
  11497. // Check if move is required
  11498. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11499. if (this.isVertical) {
  11500. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11501. }
  11502. else {
  11503. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11504. }
  11505. }
  11506. }
  11507. // Delta mode
  11508. var delta = 0;
  11509. if (this.isVertical) {
  11510. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11511. }
  11512. else {
  11513. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11514. }
  11515. this.value += delta * (this.maximum - this.minimum);
  11516. this._originX = x;
  11517. this._originY = y;
  11518. };
  11519. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11520. this._first = true;
  11521. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11522. };
  11523. return ScrollBar;
  11524. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11525. /***/ }),
  11526. /***/ "./2D/controls/sliders/slider.ts":
  11527. /*!***************************************!*\
  11528. !*** ./2D/controls/sliders/slider.ts ***!
  11529. \***************************************/
  11530. /*! exports provided: Slider */
  11531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11532. "use strict";
  11533. __webpack_require__.r(__webpack_exports__);
  11534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11536. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11537. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  11538. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11539. /**
  11540. * Class used to create slider controls
  11541. */
  11542. var Slider = /** @class */ (function (_super) {
  11543. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11544. /**
  11545. * Creates a new Slider
  11546. * @param name defines the control name
  11547. */
  11548. function Slider(name) {
  11549. var _this = _super.call(this, name) || this;
  11550. _this.name = name;
  11551. _this._background = "black";
  11552. _this._borderColor = "white";
  11553. _this._isThumbCircle = false;
  11554. _this._displayValueBar = true;
  11555. return _this;
  11556. }
  11557. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11558. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11559. get: function () {
  11560. return this._displayValueBar;
  11561. },
  11562. set: function (value) {
  11563. if (this._displayValueBar === value) {
  11564. return;
  11565. }
  11566. this._displayValueBar = value;
  11567. this._markAsDirty();
  11568. },
  11569. enumerable: false,
  11570. configurable: true
  11571. });
  11572. Object.defineProperty(Slider.prototype, "borderColor", {
  11573. /** Gets or sets border color */
  11574. get: function () {
  11575. return this._borderColor;
  11576. },
  11577. set: function (value) {
  11578. if (this._borderColor === value) {
  11579. return;
  11580. }
  11581. this._borderColor = value;
  11582. this._markAsDirty();
  11583. },
  11584. enumerable: false,
  11585. configurable: true
  11586. });
  11587. Object.defineProperty(Slider.prototype, "background", {
  11588. /** Gets or sets background color */
  11589. get: function () {
  11590. return this._background;
  11591. },
  11592. set: function (value) {
  11593. if (this._background === value) {
  11594. return;
  11595. }
  11596. this._background = value;
  11597. this._markAsDirty();
  11598. },
  11599. enumerable: false,
  11600. configurable: true
  11601. });
  11602. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11603. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11604. get: function () {
  11605. return this._isThumbCircle;
  11606. },
  11607. set: function (value) {
  11608. if (this._isThumbCircle === value) {
  11609. return;
  11610. }
  11611. this._isThumbCircle = value;
  11612. this._markAsDirty();
  11613. },
  11614. enumerable: false,
  11615. configurable: true
  11616. });
  11617. Slider.prototype._getTypeName = function () {
  11618. return "Slider";
  11619. };
  11620. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11621. context.save();
  11622. this._applyStates(context);
  11623. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11624. var left = this._renderLeft;
  11625. var top = this._renderTop;
  11626. var width = this._renderWidth;
  11627. var height = this._renderHeight;
  11628. var radius = 0;
  11629. if (this.isThumbClamped && this.isThumbCircle) {
  11630. if (this.isVertical) {
  11631. top += (this._effectiveThumbThickness / 2);
  11632. }
  11633. else {
  11634. left += (this._effectiveThumbThickness / 2);
  11635. }
  11636. radius = this._backgroundBoxThickness / 2;
  11637. }
  11638. else {
  11639. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11640. }
  11641. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11642. context.shadowColor = this.shadowColor;
  11643. context.shadowBlur = this.shadowBlur;
  11644. context.shadowOffsetX = this.shadowOffsetX;
  11645. context.shadowOffsetY = this.shadowOffsetY;
  11646. }
  11647. var thumbPosition = this._getThumbPosition();
  11648. context.fillStyle = this._background;
  11649. if (this.isVertical) {
  11650. if (this.isThumbClamped) {
  11651. if (this.isThumbCircle) {
  11652. context.beginPath();
  11653. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11654. context.fill();
  11655. context.fillRect(left, top, width, height);
  11656. }
  11657. else {
  11658. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11659. }
  11660. }
  11661. else {
  11662. context.fillRect(left, top, width, height);
  11663. }
  11664. }
  11665. else {
  11666. if (this.isThumbClamped) {
  11667. if (this.isThumbCircle) {
  11668. context.beginPath();
  11669. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11670. context.fill();
  11671. context.fillRect(left, top, width, height);
  11672. }
  11673. else {
  11674. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11675. }
  11676. }
  11677. else {
  11678. context.fillRect(left, top, width, height);
  11679. }
  11680. }
  11681. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11682. context.shadowBlur = 0;
  11683. context.shadowOffsetX = 0;
  11684. context.shadowOffsetY = 0;
  11685. }
  11686. // Value bar
  11687. context.fillStyle = this.color;
  11688. if (this._displayValueBar) {
  11689. if (this.isVertical) {
  11690. if (this.isThumbClamped) {
  11691. if (this.isThumbCircle) {
  11692. context.beginPath();
  11693. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11694. context.fill();
  11695. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11696. }
  11697. else {
  11698. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11699. }
  11700. }
  11701. else {
  11702. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11703. }
  11704. }
  11705. else {
  11706. if (this.isThumbClamped) {
  11707. if (this.isThumbCircle) {
  11708. context.beginPath();
  11709. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11710. context.fill();
  11711. context.fillRect(left, top, thumbPosition, height);
  11712. }
  11713. else {
  11714. context.fillRect(left, top, thumbPosition, height);
  11715. }
  11716. }
  11717. else {
  11718. context.fillRect(left, top, thumbPosition, height);
  11719. }
  11720. }
  11721. }
  11722. // Thumb
  11723. if (this.displayThumb) {
  11724. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11725. context.shadowColor = this.shadowColor;
  11726. context.shadowBlur = this.shadowBlur;
  11727. context.shadowOffsetX = this.shadowOffsetX;
  11728. context.shadowOffsetY = this.shadowOffsetY;
  11729. }
  11730. if (this._isThumbCircle) {
  11731. context.beginPath();
  11732. if (this.isVertical) {
  11733. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11734. }
  11735. else {
  11736. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11737. }
  11738. context.fill();
  11739. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11740. context.shadowBlur = 0;
  11741. context.shadowOffsetX = 0;
  11742. context.shadowOffsetY = 0;
  11743. }
  11744. context.strokeStyle = this._borderColor;
  11745. context.stroke();
  11746. }
  11747. else {
  11748. if (this.isVertical) {
  11749. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11750. }
  11751. else {
  11752. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11753. }
  11754. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11755. context.shadowBlur = 0;
  11756. context.shadowOffsetX = 0;
  11757. context.shadowOffsetY = 0;
  11758. }
  11759. context.strokeStyle = this._borderColor;
  11760. if (this.isVertical) {
  11761. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11762. }
  11763. else {
  11764. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11765. }
  11766. }
  11767. }
  11768. context.restore();
  11769. };
  11770. return Slider;
  11771. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11772. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11773. /***/ }),
  11774. /***/ "./2D/controls/stackPanel.ts":
  11775. /*!***********************************!*\
  11776. !*** ./2D/controls/stackPanel.ts ***!
  11777. \***********************************/
  11778. /*! exports provided: StackPanel */
  11779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11780. "use strict";
  11781. __webpack_require__.r(__webpack_exports__);
  11782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11783. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11784. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  11785. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11786. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11787. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11788. /**
  11789. * Class used to create a 2D stack panel container
  11790. */
  11791. var StackPanel = /** @class */ (function (_super) {
  11792. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11793. /**
  11794. * Creates a new StackPanel
  11795. * @param name defines control name
  11796. */
  11797. function StackPanel(name) {
  11798. var _this = _super.call(this, name) || this;
  11799. _this.name = name;
  11800. _this._isVertical = true;
  11801. _this._manualWidth = false;
  11802. _this._manualHeight = false;
  11803. _this._doNotTrackManualChanges = false;
  11804. /**
  11805. * Gets or sets a boolean indicating that layou warnings should be ignored
  11806. */
  11807. _this.ignoreLayoutWarnings = false;
  11808. return _this;
  11809. }
  11810. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11811. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11812. get: function () {
  11813. return this._isVertical;
  11814. },
  11815. set: function (value) {
  11816. if (this._isVertical === value) {
  11817. return;
  11818. }
  11819. this._isVertical = value;
  11820. this._markAsDirty();
  11821. },
  11822. enumerable: false,
  11823. configurable: true
  11824. });
  11825. Object.defineProperty(StackPanel.prototype, "width", {
  11826. get: function () {
  11827. return this._width.toString(this._host);
  11828. },
  11829. /**
  11830. * Gets or sets panel width.
  11831. * This value should not be set when in horizontal mode as it will be computed automatically
  11832. */
  11833. set: function (value) {
  11834. if (!this._doNotTrackManualChanges) {
  11835. this._manualWidth = true;
  11836. }
  11837. if (this._width.toString(this._host) === value) {
  11838. return;
  11839. }
  11840. if (this._width.fromString(value)) {
  11841. this._markAsDirty();
  11842. }
  11843. },
  11844. enumerable: false,
  11845. configurable: true
  11846. });
  11847. Object.defineProperty(StackPanel.prototype, "height", {
  11848. get: function () {
  11849. return this._height.toString(this._host);
  11850. },
  11851. /**
  11852. * Gets or sets panel height.
  11853. * This value should not be set when in vertical mode as it will be computed automatically
  11854. */
  11855. set: function (value) {
  11856. if (!this._doNotTrackManualChanges) {
  11857. this._manualHeight = true;
  11858. }
  11859. if (this._height.toString(this._host) === value) {
  11860. return;
  11861. }
  11862. if (this._height.fromString(value)) {
  11863. this._markAsDirty();
  11864. }
  11865. },
  11866. enumerable: false,
  11867. configurable: true
  11868. });
  11869. StackPanel.prototype._getTypeName = function () {
  11870. return "StackPanel";
  11871. };
  11872. /** @hidden */
  11873. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11874. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11875. var child = _a[_i];
  11876. if (this._isVertical) {
  11877. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11878. }
  11879. else {
  11880. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11881. }
  11882. }
  11883. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11884. };
  11885. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11886. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11887. this._measureForChildren.copyFrom(parentMeasure);
  11888. this._measureForChildren.left = this._currentMeasure.left;
  11889. this._measureForChildren.top = this._currentMeasure.top;
  11890. if (!this.isVertical || this._manualWidth) {
  11891. this._measureForChildren.width = this._currentMeasure.width;
  11892. }
  11893. if (this.isVertical || this._manualHeight) {
  11894. this._measureForChildren.height = this._currentMeasure.height;
  11895. }
  11896. };
  11897. StackPanel.prototype._postMeasure = function () {
  11898. var stackWidth = 0;
  11899. var stackHeight = 0;
  11900. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11901. var child = _a[_i];
  11902. if (!child.isVisible || child.notRenderable) {
  11903. continue;
  11904. }
  11905. if (this._isVertical) {
  11906. if (child.top !== stackHeight + "px") {
  11907. child.top = stackHeight + "px";
  11908. this._rebuildLayout = true;
  11909. child._top.ignoreAdaptiveScaling = true;
  11910. }
  11911. if (child._height.isPercentage && !child._automaticSize) {
  11912. if (!this.ignoreLayoutWarnings) {
  11913. 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");
  11914. }
  11915. }
  11916. else {
  11917. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11918. }
  11919. }
  11920. else {
  11921. if (child.left !== stackWidth + "px") {
  11922. child.left = stackWidth + "px";
  11923. this._rebuildLayout = true;
  11924. child._left.ignoreAdaptiveScaling = true;
  11925. }
  11926. if (child._width.isPercentage && !child._automaticSize) {
  11927. if (!this.ignoreLayoutWarnings) {
  11928. 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");
  11929. }
  11930. }
  11931. else {
  11932. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11933. }
  11934. }
  11935. }
  11936. this._doNotTrackManualChanges = true;
  11937. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11938. // User can now define their own height and width for stack panel.
  11939. var panelWidthChanged = false;
  11940. var panelHeightChanged = false;
  11941. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11942. var previousHeight = this.height;
  11943. this.height = stackHeight + "px";
  11944. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11945. }
  11946. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11947. var previousWidth = this.width;
  11948. this.width = stackWidth + "px";
  11949. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11950. }
  11951. if (panelHeightChanged) {
  11952. this._height.ignoreAdaptiveScaling = true;
  11953. }
  11954. if (panelWidthChanged) {
  11955. this._width.ignoreAdaptiveScaling = true;
  11956. }
  11957. this._doNotTrackManualChanges = false;
  11958. if (panelWidthChanged || panelHeightChanged) {
  11959. this._rebuildLayout = true;
  11960. }
  11961. _super.prototype._postMeasure.call(this);
  11962. };
  11963. return StackPanel;
  11964. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11965. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11966. /***/ }),
  11967. /***/ "./2D/controls/statics.ts":
  11968. /*!********************************!*\
  11969. !*** ./2D/controls/statics.ts ***!
  11970. \********************************/
  11971. /*! exports provided: name */
  11972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11973. "use strict";
  11974. __webpack_require__.r(__webpack_exports__);
  11975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11976. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11977. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11978. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11979. /**
  11980. * Forcing an export so that this code will execute
  11981. * @hidden
  11982. */
  11983. var name = "Statics";
  11984. /**
  11985. * Creates a stack panel that can be used to render headers
  11986. * @param control defines the control to associate with the header
  11987. * @param text defines the text of the header
  11988. * @param size defines the size of the header
  11989. * @param options defines options used to configure the header
  11990. * @returns a new StackPanel
  11991. */
  11992. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11993. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11994. var isHorizontal = options ? options.isHorizontal : true;
  11995. var controlFirst = options ? options.controlFirst : true;
  11996. panel.isVertical = !isHorizontal;
  11997. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11998. header.text = text;
  11999. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12000. if (isHorizontal) {
  12001. header.width = size;
  12002. }
  12003. else {
  12004. header.height = size;
  12005. }
  12006. if (controlFirst) {
  12007. panel.addControl(control);
  12008. panel.addControl(header);
  12009. header.paddingLeft = "5px";
  12010. }
  12011. else {
  12012. panel.addControl(header);
  12013. panel.addControl(control);
  12014. header.paddingRight = "5px";
  12015. }
  12016. header.shadowBlur = control.shadowBlur;
  12017. header.shadowColor = control.shadowColor;
  12018. header.shadowOffsetX = control.shadowOffsetX;
  12019. header.shadowOffsetY = control.shadowOffsetY;
  12020. return panel;
  12021. };
  12022. /***/ }),
  12023. /***/ "./2D/controls/textBlock.ts":
  12024. /*!**********************************!*\
  12025. !*** ./2D/controls/textBlock.ts ***!
  12026. \**********************************/
  12027. /*! exports provided: TextWrapping, TextBlock */
  12028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12029. "use strict";
  12030. __webpack_require__.r(__webpack_exports__);
  12031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12033. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12034. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  12035. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12036. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12037. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12038. /**
  12039. * Enum that determines the text-wrapping mode to use.
  12040. */
  12041. var TextWrapping;
  12042. (function (TextWrapping) {
  12043. /**
  12044. * Clip the text when it's larger than Control.width; this is the default mode.
  12045. */
  12046. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12047. /**
  12048. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12049. */
  12050. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12051. /**
  12052. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12053. */
  12054. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12055. })(TextWrapping || (TextWrapping = {}));
  12056. /**
  12057. * Class used to create text block control
  12058. */
  12059. var TextBlock = /** @class */ (function (_super) {
  12060. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12061. /**
  12062. * Creates a new TextBlock object
  12063. * @param name defines the name of the control
  12064. * @param text defines the text to display (emptry string by default)
  12065. */
  12066. function TextBlock(
  12067. /**
  12068. * Defines the name of the control
  12069. */
  12070. name, text) {
  12071. if (text === void 0) { text = ""; }
  12072. var _this = _super.call(this, name) || this;
  12073. _this.name = name;
  12074. _this._text = "";
  12075. _this._textWrapping = TextWrapping.Clip;
  12076. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12077. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12078. _this._resizeToFit = false;
  12079. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12080. _this._outlineWidth = 0;
  12081. _this._outlineColor = "white";
  12082. /**
  12083. * An event triggered after the text is changed
  12084. */
  12085. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12086. /**
  12087. * An event triggered after the text was broken up into lines
  12088. */
  12089. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12090. _this.text = text;
  12091. return _this;
  12092. }
  12093. Object.defineProperty(TextBlock.prototype, "lines", {
  12094. /**
  12095. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12096. */
  12097. get: function () {
  12098. return this._lines;
  12099. },
  12100. enumerable: false,
  12101. configurable: true
  12102. });
  12103. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12104. /**
  12105. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12106. */
  12107. get: function () {
  12108. return this._resizeToFit;
  12109. },
  12110. /**
  12111. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12112. */
  12113. set: function (value) {
  12114. if (this._resizeToFit === value) {
  12115. return;
  12116. }
  12117. this._resizeToFit = value;
  12118. if (this._resizeToFit) {
  12119. this._width.ignoreAdaptiveScaling = true;
  12120. this._height.ignoreAdaptiveScaling = true;
  12121. }
  12122. this._markAsDirty();
  12123. },
  12124. enumerable: false,
  12125. configurable: true
  12126. });
  12127. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12128. /**
  12129. * Gets or sets a boolean indicating if text must be wrapped
  12130. */
  12131. get: function () {
  12132. return this._textWrapping;
  12133. },
  12134. /**
  12135. * Gets or sets a boolean indicating if text must be wrapped
  12136. */
  12137. set: function (value) {
  12138. if (this._textWrapping === value) {
  12139. return;
  12140. }
  12141. this._textWrapping = +value;
  12142. this._markAsDirty();
  12143. },
  12144. enumerable: false,
  12145. configurable: true
  12146. });
  12147. Object.defineProperty(TextBlock.prototype, "text", {
  12148. /**
  12149. * Gets or sets text to display
  12150. */
  12151. get: function () {
  12152. return this._text;
  12153. },
  12154. /**
  12155. * Gets or sets text to display
  12156. */
  12157. set: function (value) {
  12158. if (this._text === value) {
  12159. return;
  12160. }
  12161. this._text = value;
  12162. this._markAsDirty();
  12163. this.onTextChangedObservable.notifyObservers(this);
  12164. },
  12165. enumerable: false,
  12166. configurable: true
  12167. });
  12168. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12169. /**
  12170. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12171. */
  12172. get: function () {
  12173. return this._textHorizontalAlignment;
  12174. },
  12175. /**
  12176. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12177. */
  12178. set: function (value) {
  12179. if (this._textHorizontalAlignment === value) {
  12180. return;
  12181. }
  12182. this._textHorizontalAlignment = value;
  12183. this._markAsDirty();
  12184. },
  12185. enumerable: false,
  12186. configurable: true
  12187. });
  12188. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12189. /**
  12190. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12191. */
  12192. get: function () {
  12193. return this._textVerticalAlignment;
  12194. },
  12195. /**
  12196. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12197. */
  12198. set: function (value) {
  12199. if (this._textVerticalAlignment === value) {
  12200. return;
  12201. }
  12202. this._textVerticalAlignment = value;
  12203. this._markAsDirty();
  12204. },
  12205. enumerable: false,
  12206. configurable: true
  12207. });
  12208. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12209. /**
  12210. * Gets or sets line spacing value
  12211. */
  12212. get: function () {
  12213. return this._lineSpacing.toString(this._host);
  12214. },
  12215. /**
  12216. * Gets or sets line spacing value
  12217. */
  12218. set: function (value) {
  12219. if (this._lineSpacing.fromString(value)) {
  12220. this._markAsDirty();
  12221. }
  12222. },
  12223. enumerable: false,
  12224. configurable: true
  12225. });
  12226. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12227. /**
  12228. * Gets or sets outlineWidth of the text to display
  12229. */
  12230. get: function () {
  12231. return this._outlineWidth;
  12232. },
  12233. /**
  12234. * Gets or sets outlineWidth of the text to display
  12235. */
  12236. set: function (value) {
  12237. if (this._outlineWidth === value) {
  12238. return;
  12239. }
  12240. this._outlineWidth = value;
  12241. this._markAsDirty();
  12242. },
  12243. enumerable: false,
  12244. configurable: true
  12245. });
  12246. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12247. /**
  12248. * Gets or sets outlineColor of the text to display
  12249. */
  12250. get: function () {
  12251. return this._outlineColor;
  12252. },
  12253. /**
  12254. * Gets or sets outlineColor of the text to display
  12255. */
  12256. set: function (value) {
  12257. if (this._outlineColor === value) {
  12258. return;
  12259. }
  12260. this._outlineColor = value;
  12261. this._markAsDirty();
  12262. },
  12263. enumerable: false,
  12264. configurable: true
  12265. });
  12266. TextBlock.prototype._getTypeName = function () {
  12267. return "TextBlock";
  12268. };
  12269. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12270. if (!this._fontOffset) {
  12271. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12272. }
  12273. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12274. // Prepare lines
  12275. this._lines = this._breakLines(this._currentMeasure.width, context);
  12276. this.onLinesReadyObservable.notifyObservers(this);
  12277. var maxLineWidth = 0;
  12278. for (var i = 0; i < this._lines.length; i++) {
  12279. var line = this._lines[i];
  12280. if (line.width > maxLineWidth) {
  12281. maxLineWidth = line.width;
  12282. }
  12283. }
  12284. if (this._resizeToFit) {
  12285. if (this._textWrapping === TextWrapping.Clip) {
  12286. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12287. if (newWidth !== this._width.internalValue) {
  12288. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12289. this._rebuildLayout = true;
  12290. }
  12291. }
  12292. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12293. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12294. var lineSpacing = 0;
  12295. if (this._lineSpacing.isPixel) {
  12296. lineSpacing = this._lineSpacing.getValue(this._host);
  12297. }
  12298. else {
  12299. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12300. }
  12301. newHeight += (this._lines.length - 1) * lineSpacing;
  12302. }
  12303. if (newHeight !== this._height.internalValue) {
  12304. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12305. this._rebuildLayout = true;
  12306. }
  12307. }
  12308. };
  12309. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12310. var width = this._currentMeasure.width;
  12311. var x = 0;
  12312. switch (this._textHorizontalAlignment) {
  12313. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12314. x = 0;
  12315. break;
  12316. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12317. x = width - textWidth;
  12318. break;
  12319. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12320. x = (width - textWidth) / 2;
  12321. break;
  12322. }
  12323. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12324. context.shadowColor = this.shadowColor;
  12325. context.shadowBlur = this.shadowBlur;
  12326. context.shadowOffsetX = this.shadowOffsetX;
  12327. context.shadowOffsetY = this.shadowOffsetY;
  12328. }
  12329. if (this.outlineWidth) {
  12330. context.strokeText(text, this._currentMeasure.left + x, y);
  12331. }
  12332. context.fillText(text, this._currentMeasure.left + x, y);
  12333. };
  12334. /** @hidden */
  12335. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12336. context.save();
  12337. this._applyStates(context);
  12338. // Render lines
  12339. this._renderLines(context);
  12340. context.restore();
  12341. };
  12342. TextBlock.prototype._applyStates = function (context) {
  12343. _super.prototype._applyStates.call(this, context);
  12344. if (this.outlineWidth) {
  12345. context.lineWidth = this.outlineWidth;
  12346. context.strokeStyle = this.outlineColor;
  12347. }
  12348. };
  12349. TextBlock.prototype._breakLines = function (refWidth, context) {
  12350. var lines = [];
  12351. var _lines = this.text.split("\n");
  12352. if (this._textWrapping === TextWrapping.Ellipsis) {
  12353. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12354. var _line = _lines_1[_i];
  12355. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12356. }
  12357. }
  12358. else if (this._textWrapping === TextWrapping.WordWrap) {
  12359. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12360. var _line = _lines_2[_a];
  12361. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12362. }
  12363. }
  12364. else {
  12365. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12366. var _line = _lines_3[_b];
  12367. lines.push(this._parseLine(_line, context));
  12368. }
  12369. }
  12370. return lines;
  12371. };
  12372. TextBlock.prototype._parseLine = function (line, context) {
  12373. if (line === void 0) { line = ''; }
  12374. return { text: line, width: context.measureText(line).width };
  12375. };
  12376. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12377. if (line === void 0) { line = ''; }
  12378. var lineWidth = context.measureText(line).width;
  12379. if (lineWidth > width) {
  12380. line += '…';
  12381. }
  12382. while (line.length > 2 && lineWidth > width) {
  12383. line = line.slice(0, -2) + '…';
  12384. lineWidth = context.measureText(line).width;
  12385. }
  12386. return { text: line, width: lineWidth };
  12387. };
  12388. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12389. if (line === void 0) { line = ''; }
  12390. var lines = [];
  12391. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(' ');
  12392. var lineWidth = 0;
  12393. for (var n = 0; n < words.length; n++) {
  12394. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12395. var metrics = context.measureText(testLine);
  12396. var testWidth = metrics.width;
  12397. if (testWidth > width && n > 0) {
  12398. lines.push({ text: line, width: lineWidth });
  12399. line = words[n];
  12400. lineWidth = context.measureText(line).width;
  12401. }
  12402. else {
  12403. lineWidth = testWidth;
  12404. line = testLine;
  12405. }
  12406. }
  12407. lines.push({ text: line, width: lineWidth });
  12408. return lines;
  12409. };
  12410. TextBlock.prototype._renderLines = function (context) {
  12411. var height = this._currentMeasure.height;
  12412. var rootY = 0;
  12413. switch (this._textVerticalAlignment) {
  12414. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12415. rootY = this._fontOffset.ascent;
  12416. break;
  12417. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12418. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12419. break;
  12420. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12421. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12422. break;
  12423. }
  12424. rootY += this._currentMeasure.top;
  12425. for (var i = 0; i < this._lines.length; i++) {
  12426. var line = this._lines[i];
  12427. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12428. if (this._lineSpacing.isPixel) {
  12429. rootY += this._lineSpacing.getValue(this._host);
  12430. }
  12431. else {
  12432. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12433. }
  12434. }
  12435. this._drawText(line.text, line.width, rootY, context);
  12436. rootY += this._fontOffset.height;
  12437. }
  12438. };
  12439. /**
  12440. * Given a width constraint applied on the text block, find the expected height
  12441. * @returns expected height
  12442. */
  12443. TextBlock.prototype.computeExpectedHeight = function () {
  12444. if (this.text && this.widthInPixels) {
  12445. var context_1 = document.createElement('canvas').getContext('2d');
  12446. if (context_1) {
  12447. this._applyStates(context_1);
  12448. if (!this._fontOffset) {
  12449. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12450. }
  12451. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12452. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12453. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12454. var lineSpacing = 0;
  12455. if (this._lineSpacing.isPixel) {
  12456. lineSpacing = this._lineSpacing.getValue(this._host);
  12457. }
  12458. else {
  12459. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12460. }
  12461. newHeight += (lines.length - 1) * lineSpacing;
  12462. }
  12463. return newHeight;
  12464. }
  12465. }
  12466. return 0;
  12467. };
  12468. TextBlock.prototype.dispose = function () {
  12469. _super.prototype.dispose.call(this);
  12470. this.onTextChangedObservable.clear();
  12471. };
  12472. return TextBlock;
  12473. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12474. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12475. /***/ }),
  12476. /***/ "./2D/controls/virtualKeyboard.ts":
  12477. /*!****************************************!*\
  12478. !*** ./2D/controls/virtualKeyboard.ts ***!
  12479. \****************************************/
  12480. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12482. "use strict";
  12483. __webpack_require__.r(__webpack_exports__);
  12484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12486. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12487. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  12488. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12489. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12490. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12491. /**
  12492. * Class used to store key control properties
  12493. */
  12494. var KeyPropertySet = /** @class */ (function () {
  12495. function KeyPropertySet() {
  12496. }
  12497. return KeyPropertySet;
  12498. }());
  12499. /**
  12500. * Class used to create virtual keyboard
  12501. */
  12502. var VirtualKeyboard = /** @class */ (function (_super) {
  12503. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12504. function VirtualKeyboard() {
  12505. var _this = _super !== null && _super.apply(this, arguments) || this;
  12506. /** Observable raised when a key is pressed */
  12507. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12508. /** Gets or sets default key button width */
  12509. _this.defaultButtonWidth = "40px";
  12510. /** Gets or sets default key button height */
  12511. _this.defaultButtonHeight = "40px";
  12512. /** Gets or sets default key button left padding */
  12513. _this.defaultButtonPaddingLeft = "2px";
  12514. /** Gets or sets default key button right padding */
  12515. _this.defaultButtonPaddingRight = "2px";
  12516. /** Gets or sets default key button top padding */
  12517. _this.defaultButtonPaddingTop = "2px";
  12518. /** Gets or sets default key button bottom padding */
  12519. _this.defaultButtonPaddingBottom = "2px";
  12520. /** Gets or sets default key button foreground color */
  12521. _this.defaultButtonColor = "#DDD";
  12522. /** Gets or sets default key button background color */
  12523. _this.defaultButtonBackground = "#070707";
  12524. /** Gets or sets shift button foreground color */
  12525. _this.shiftButtonColor = "#7799FF";
  12526. /** Gets or sets shift button thickness*/
  12527. _this.selectedShiftThickness = 1;
  12528. /** Gets shift key state */
  12529. _this.shiftState = 0;
  12530. _this._currentlyConnectedInputText = null;
  12531. _this._connectedInputTexts = [];
  12532. _this._onKeyPressObserver = null;
  12533. return _this;
  12534. }
  12535. VirtualKeyboard.prototype._getTypeName = function () {
  12536. return "VirtualKeyboard";
  12537. };
  12538. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12539. var _this = this;
  12540. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12541. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12542. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12543. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12544. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12545. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12546. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12547. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12548. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12549. button.thickness = 0;
  12550. button.isFocusInvisible = true;
  12551. button.shadowColor = this.shadowColor;
  12552. button.shadowBlur = this.shadowBlur;
  12553. button.shadowOffsetX = this.shadowOffsetX;
  12554. button.shadowOffsetY = this.shadowOffsetY;
  12555. button.onPointerUpObservable.add(function () {
  12556. _this.onKeyPressObservable.notifyObservers(key);
  12557. });
  12558. return button;
  12559. };
  12560. /**
  12561. * Adds a new row of keys
  12562. * @param keys defines the list of keys to add
  12563. * @param propertySets defines the associated property sets
  12564. */
  12565. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12566. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12567. panel.isVertical = false;
  12568. panel.isFocusInvisible = true;
  12569. var maxKey = null;
  12570. for (var i = 0; i < keys.length; i++) {
  12571. var properties = null;
  12572. if (propertySets && propertySets.length === keys.length) {
  12573. properties = propertySets[i];
  12574. }
  12575. var key = this._createKey(keys[i], properties);
  12576. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12577. maxKey = key;
  12578. }
  12579. panel.addControl(key);
  12580. }
  12581. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12582. this.addControl(panel);
  12583. };
  12584. /**
  12585. * Set the shift key to a specific state
  12586. * @param shiftState defines the new shift state
  12587. */
  12588. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12589. if (!this.children) {
  12590. return;
  12591. }
  12592. for (var i = 0; i < this.children.length; i++) {
  12593. var row = this.children[i];
  12594. if (!row || !row.children) {
  12595. continue;
  12596. }
  12597. var rowContainer = row;
  12598. for (var j = 0; j < rowContainer.children.length; j++) {
  12599. var button = rowContainer.children[j];
  12600. if (!button || !button.children[0]) {
  12601. continue;
  12602. }
  12603. var button_tblock = button.children[0];
  12604. if (button_tblock.text === "\u21E7") {
  12605. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12606. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12607. }
  12608. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12609. }
  12610. }
  12611. };
  12612. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12613. /** Gets the input text control currently attached to the keyboard */
  12614. get: function () {
  12615. return this._currentlyConnectedInputText;
  12616. },
  12617. enumerable: false,
  12618. configurable: true
  12619. });
  12620. /**
  12621. * Connects the keyboard with an input text control
  12622. *
  12623. * @param input defines the target control
  12624. */
  12625. VirtualKeyboard.prototype.connect = function (input) {
  12626. var _this = this;
  12627. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12628. if (inputTextAlreadyConnected) {
  12629. return;
  12630. }
  12631. if (this._onKeyPressObserver === null) {
  12632. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12633. if (!_this._currentlyConnectedInputText) {
  12634. return;
  12635. }
  12636. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12637. switch (key) {
  12638. case "\u21E7":
  12639. _this.shiftState++;
  12640. if (_this.shiftState > 2) {
  12641. _this.shiftState = 0;
  12642. }
  12643. _this.applyShiftState(_this.shiftState);
  12644. return;
  12645. case "\u2190":
  12646. _this._currentlyConnectedInputText.processKey(8);
  12647. return;
  12648. case "\u21B5":
  12649. _this._currentlyConnectedInputText.processKey(13);
  12650. return;
  12651. }
  12652. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12653. if (_this.shiftState === 1) {
  12654. _this.shiftState = 0;
  12655. _this.applyShiftState(_this.shiftState);
  12656. }
  12657. });
  12658. }
  12659. this.isVisible = false;
  12660. this._currentlyConnectedInputText = input;
  12661. input._connectedVirtualKeyboard = this;
  12662. // Events hooking
  12663. var onFocusObserver = input.onFocusObservable.add(function () {
  12664. _this._currentlyConnectedInputText = input;
  12665. input._connectedVirtualKeyboard = _this;
  12666. _this.isVisible = true;
  12667. });
  12668. var onBlurObserver = input.onBlurObservable.add(function () {
  12669. input._connectedVirtualKeyboard = null;
  12670. _this._currentlyConnectedInputText = null;
  12671. _this.isVisible = false;
  12672. });
  12673. this._connectedInputTexts.push({
  12674. input: input,
  12675. onBlurObserver: onBlurObserver,
  12676. onFocusObserver: onFocusObserver
  12677. });
  12678. };
  12679. /**
  12680. * Disconnects the keyboard from connected InputText controls
  12681. *
  12682. * @param input optionally defines a target control, otherwise all are disconnected
  12683. */
  12684. VirtualKeyboard.prototype.disconnect = function (input) {
  12685. var _this = this;
  12686. if (input) {
  12687. // .find not available on IE
  12688. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12689. if (filtered.length === 1) {
  12690. this._removeConnectedInputObservables(filtered[0]);
  12691. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12692. if (this._currentlyConnectedInputText === input) {
  12693. this._currentlyConnectedInputText = null;
  12694. }
  12695. }
  12696. }
  12697. else {
  12698. this._connectedInputTexts.forEach(function (connectedInputText) {
  12699. _this._removeConnectedInputObservables(connectedInputText);
  12700. });
  12701. this._connectedInputTexts = [];
  12702. }
  12703. if (this._connectedInputTexts.length === 0) {
  12704. this._currentlyConnectedInputText = null;
  12705. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12706. this._onKeyPressObserver = null;
  12707. }
  12708. };
  12709. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12710. connectedInputText.input._connectedVirtualKeyboard = null;
  12711. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12712. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12713. };
  12714. /**
  12715. * Release all resources
  12716. */
  12717. VirtualKeyboard.prototype.dispose = function () {
  12718. _super.prototype.dispose.call(this);
  12719. this.disconnect();
  12720. };
  12721. // Statics
  12722. /**
  12723. * Creates a new keyboard using a default layout
  12724. *
  12725. * @param name defines control name
  12726. * @returns a new VirtualKeyboard
  12727. */
  12728. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12729. var returnValue = new VirtualKeyboard(name);
  12730. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12731. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12732. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12733. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12734. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12735. return returnValue;
  12736. };
  12737. return VirtualKeyboard;
  12738. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12739. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12740. /***/ }),
  12741. /***/ "./2D/index.ts":
  12742. /*!*********************!*\
  12743. !*** ./2D/index.ts ***!
  12744. \*********************/
  12745. /*! 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 */
  12746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12747. "use strict";
  12748. __webpack_require__.r(__webpack_exports__);
  12749. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12782. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12784. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12786. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12789. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12791. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12793. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12795. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12797. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12799. /***/ }),
  12800. /***/ "./2D/math2D.ts":
  12801. /*!**********************!*\
  12802. !*** ./2D/math2D.ts ***!
  12803. \**********************/
  12804. /*! exports provided: Vector2WithInfo, Matrix2D */
  12805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12806. "use strict";
  12807. __webpack_require__.r(__webpack_exports__);
  12808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12810. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12811. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  12812. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12813. /**
  12814. * Class used to transport Vector2 information for pointer events
  12815. */
  12816. var Vector2WithInfo = /** @class */ (function (_super) {
  12817. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12818. /**
  12819. * Creates a new Vector2WithInfo
  12820. * @param source defines the vector2 data to transport
  12821. * @param buttonIndex defines the current mouse button index
  12822. */
  12823. function Vector2WithInfo(source,
  12824. /** defines the current mouse button index */
  12825. buttonIndex) {
  12826. if (buttonIndex === void 0) { buttonIndex = 0; }
  12827. var _this = _super.call(this, source.x, source.y) || this;
  12828. _this.buttonIndex = buttonIndex;
  12829. return _this;
  12830. }
  12831. return Vector2WithInfo;
  12832. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12833. /** Class used to provide 2D matrix features */
  12834. var Matrix2D = /** @class */ (function () {
  12835. /**
  12836. * Creates a new matrix
  12837. * @param m00 defines value for (0, 0)
  12838. * @param m01 defines value for (0, 1)
  12839. * @param m10 defines value for (1, 0)
  12840. * @param m11 defines value for (1, 1)
  12841. * @param m20 defines value for (2, 0)
  12842. * @param m21 defines value for (2, 1)
  12843. */
  12844. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12845. /** Gets the internal array of 6 floats used to store matrix data */
  12846. this.m = new Float32Array(6);
  12847. this.fromValues(m00, m01, m10, m11, m20, m21);
  12848. }
  12849. /**
  12850. * Fills the matrix from direct values
  12851. * @param m00 defines value for (0, 0)
  12852. * @param m01 defines value for (0, 1)
  12853. * @param m10 defines value for (1, 0)
  12854. * @param m11 defines value for (1, 1)
  12855. * @param m20 defines value for (2, 0)
  12856. * @param m21 defines value for (2, 1)
  12857. * @returns the current modified matrix
  12858. */
  12859. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12860. this.m[0] = m00;
  12861. this.m[1] = m01;
  12862. this.m[2] = m10;
  12863. this.m[3] = m11;
  12864. this.m[4] = m20;
  12865. this.m[5] = m21;
  12866. return this;
  12867. };
  12868. /**
  12869. * Gets matrix determinant
  12870. * @returns the determinant
  12871. */
  12872. Matrix2D.prototype.determinant = function () {
  12873. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12874. };
  12875. /**
  12876. * Inverses the matrix and stores it in a target matrix
  12877. * @param result defines the target matrix
  12878. * @returns the current matrix
  12879. */
  12880. Matrix2D.prototype.invertToRef = function (result) {
  12881. var l0 = this.m[0];
  12882. var l1 = this.m[1];
  12883. var l2 = this.m[2];
  12884. var l3 = this.m[3];
  12885. var l4 = this.m[4];
  12886. var l5 = this.m[5];
  12887. var det = this.determinant();
  12888. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12889. result.m[0] = 0;
  12890. result.m[1] = 0;
  12891. result.m[2] = 0;
  12892. result.m[3] = 0;
  12893. result.m[4] = 0;
  12894. result.m[5] = 0;
  12895. return this;
  12896. }
  12897. var detDiv = 1 / det;
  12898. var det4 = l2 * l5 - l3 * l4;
  12899. var det5 = l1 * l4 - l0 * l5;
  12900. result.m[0] = l3 * detDiv;
  12901. result.m[1] = -l1 * detDiv;
  12902. result.m[2] = -l2 * detDiv;
  12903. result.m[3] = l0 * detDiv;
  12904. result.m[4] = det4 * detDiv;
  12905. result.m[5] = det5 * detDiv;
  12906. return this;
  12907. };
  12908. /**
  12909. * Multiplies the current matrix with another one
  12910. * @param other defines the second operand
  12911. * @param result defines the target matrix
  12912. * @returns the current matrix
  12913. */
  12914. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12915. var l0 = this.m[0];
  12916. var l1 = this.m[1];
  12917. var l2 = this.m[2];
  12918. var l3 = this.m[3];
  12919. var l4 = this.m[4];
  12920. var l5 = this.m[5];
  12921. var r0 = other.m[0];
  12922. var r1 = other.m[1];
  12923. var r2 = other.m[2];
  12924. var r3 = other.m[3];
  12925. var r4 = other.m[4];
  12926. var r5 = other.m[5];
  12927. result.m[0] = l0 * r0 + l1 * r2;
  12928. result.m[1] = l0 * r1 + l1 * r3;
  12929. result.m[2] = l2 * r0 + l3 * r2;
  12930. result.m[3] = l2 * r1 + l3 * r3;
  12931. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12932. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12933. return this;
  12934. };
  12935. /**
  12936. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12937. * @param x defines the x coordinate to transform
  12938. * @param y defines the x coordinate to transform
  12939. * @param result defines the target vector2
  12940. * @returns the current matrix
  12941. */
  12942. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12943. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12944. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12945. return this;
  12946. };
  12947. // Statics
  12948. /**
  12949. * Creates an identity matrix
  12950. * @returns a new matrix
  12951. */
  12952. Matrix2D.Identity = function () {
  12953. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12954. };
  12955. /**
  12956. * Creates a translation matrix and stores it in a target matrix
  12957. * @param x defines the x coordinate of the translation
  12958. * @param y defines the y coordinate of the translation
  12959. * @param result defines the target matrix
  12960. */
  12961. Matrix2D.TranslationToRef = function (x, y, result) {
  12962. result.fromValues(1, 0, 0, 1, x, y);
  12963. };
  12964. /**
  12965. * Creates a scaling matrix and stores it in a target matrix
  12966. * @param x defines the x coordinate of the scaling
  12967. * @param y defines the y coordinate of the scaling
  12968. * @param result defines the target matrix
  12969. */
  12970. Matrix2D.ScalingToRef = function (x, y, result) {
  12971. result.fromValues(x, 0, 0, y, 0, 0);
  12972. };
  12973. /**
  12974. * Creates a rotation matrix and stores it in a target matrix
  12975. * @param angle defines the rotation angle
  12976. * @param result defines the target matrix
  12977. */
  12978. Matrix2D.RotationToRef = function (angle, result) {
  12979. var s = Math.sin(angle);
  12980. var c = Math.cos(angle);
  12981. result.fromValues(c, s, -s, c, 0, 0);
  12982. };
  12983. /**
  12984. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12985. * @param tx defines the x coordinate of the translation
  12986. * @param ty defines the y coordinate of the translation
  12987. * @param angle defines the rotation angle
  12988. * @param scaleX defines the x coordinate of the scaling
  12989. * @param scaleY defines the y coordinate of the scaling
  12990. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12991. * @param result defines the target matrix
  12992. */
  12993. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12994. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12995. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12996. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12997. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12998. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12999. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  13000. if (parentMatrix) {
  13001. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  13002. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  13003. }
  13004. else {
  13005. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  13006. }
  13007. };
  13008. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  13009. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  13010. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  13011. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  13012. Matrix2D._TempCompose0 = Matrix2D.Identity();
  13013. Matrix2D._TempCompose1 = Matrix2D.Identity();
  13014. Matrix2D._TempCompose2 = Matrix2D.Identity();
  13015. return Matrix2D;
  13016. }());
  13017. /***/ }),
  13018. /***/ "./2D/measure.ts":
  13019. /*!***********************!*\
  13020. !*** ./2D/measure.ts ***!
  13021. \***********************/
  13022. /*! exports provided: Measure */
  13023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13024. "use strict";
  13025. __webpack_require__.r(__webpack_exports__);
  13026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  13027. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13028. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13029. var tmpRect = [
  13030. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13031. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13032. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13033. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13034. ];
  13035. var tmpRect2 = [
  13036. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13037. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13038. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13039. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13040. ];
  13041. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13042. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13043. /**
  13044. * Class used to store 2D control sizes
  13045. */
  13046. var Measure = /** @class */ (function () {
  13047. /**
  13048. * Creates a new measure
  13049. * @param left defines left coordinate
  13050. * @param top defines top coordinate
  13051. * @param width defines width dimension
  13052. * @param height defines height dimension
  13053. */
  13054. function Measure(
  13055. /** defines left coordinate */
  13056. left,
  13057. /** defines top coordinate */
  13058. top,
  13059. /** defines width dimension */
  13060. width,
  13061. /** defines height dimension */
  13062. height) {
  13063. this.left = left;
  13064. this.top = top;
  13065. this.width = width;
  13066. this.height = height;
  13067. }
  13068. /**
  13069. * Copy from another measure
  13070. * @param other defines the other measure to copy from
  13071. */
  13072. Measure.prototype.copyFrom = function (other) {
  13073. this.left = other.left;
  13074. this.top = other.top;
  13075. this.width = other.width;
  13076. this.height = other.height;
  13077. };
  13078. /**
  13079. * Copy from a group of 4 floats
  13080. * @param left defines left coordinate
  13081. * @param top defines top coordinate
  13082. * @param width defines width dimension
  13083. * @param height defines height dimension
  13084. */
  13085. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13086. this.left = left;
  13087. this.top = top;
  13088. this.width = width;
  13089. this.height = height;
  13090. };
  13091. /**
  13092. * Computes the axis aligned bounding box measure for two given measures
  13093. * @param a Input measure
  13094. * @param b Input measure
  13095. * @param result the resulting bounding measure
  13096. */
  13097. Measure.CombineToRef = function (a, b, result) {
  13098. var left = Math.min(a.left, b.left);
  13099. var top = Math.min(a.top, b.top);
  13100. var right = Math.max(a.left + a.width, b.left + b.width);
  13101. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13102. result.left = left;
  13103. result.top = top;
  13104. result.width = right - left;
  13105. result.height = bottom - top;
  13106. };
  13107. /**
  13108. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13109. * @param transform the matrix to transform the measure before computing the AABB
  13110. * @param result the resulting AABB
  13111. */
  13112. Measure.prototype.transformToRef = function (transform, result) {
  13113. tmpRect[0].copyFromFloats(this.left, this.top);
  13114. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  13115. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  13116. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  13117. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13118. tmpV2.copyFromFloats(0, 0);
  13119. for (var i = 0; i < 4; i++) {
  13120. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13121. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13122. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13123. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13124. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13125. }
  13126. result.left = tmpV1.x;
  13127. result.top = tmpV1.y;
  13128. result.width = tmpV2.x - tmpV1.x;
  13129. result.height = tmpV2.y - tmpV1.y;
  13130. };
  13131. /**
  13132. * Check equality between this measure and another one
  13133. * @param other defines the other measures
  13134. * @returns true if both measures are equals
  13135. */
  13136. Measure.prototype.isEqualsTo = function (other) {
  13137. if (this.left !== other.left) {
  13138. return false;
  13139. }
  13140. if (this.top !== other.top) {
  13141. return false;
  13142. }
  13143. if (this.width !== other.width) {
  13144. return false;
  13145. }
  13146. if (this.height !== other.height) {
  13147. return false;
  13148. }
  13149. return true;
  13150. };
  13151. /**
  13152. * Creates an empty measure
  13153. * @returns a new measure
  13154. */
  13155. Measure.Empty = function () {
  13156. return new Measure(0, 0, 0, 0);
  13157. };
  13158. return Measure;
  13159. }());
  13160. /***/ }),
  13161. /***/ "./2D/multiLinePoint.ts":
  13162. /*!******************************!*\
  13163. !*** ./2D/multiLinePoint.ts ***!
  13164. \******************************/
  13165. /*! exports provided: MultiLinePoint */
  13166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13167. "use strict";
  13168. __webpack_require__.r(__webpack_exports__);
  13169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13170. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13171. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13172. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13173. /**
  13174. * Class used to store a point for a MultiLine object.
  13175. * The point can be pure 2D coordinates, a mesh or a control
  13176. */
  13177. var MultiLinePoint = /** @class */ (function () {
  13178. /**
  13179. * Creates a new MultiLinePoint
  13180. * @param multiLine defines the source MultiLine object
  13181. */
  13182. function MultiLinePoint(multiLine) {
  13183. this._multiLine = multiLine;
  13184. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13185. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13186. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13187. }
  13188. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13189. /** Gets or sets x coordinate */
  13190. get: function () {
  13191. return this._x.toString(this._multiLine._host);
  13192. },
  13193. set: function (value) {
  13194. if (this._x.toString(this._multiLine._host) === value) {
  13195. return;
  13196. }
  13197. if (this._x.fromString(value)) {
  13198. this._multiLine._markAsDirty();
  13199. }
  13200. },
  13201. enumerable: false,
  13202. configurable: true
  13203. });
  13204. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13205. /** Gets or sets y coordinate */
  13206. get: function () {
  13207. return this._y.toString(this._multiLine._host);
  13208. },
  13209. set: function (value) {
  13210. if (this._y.toString(this._multiLine._host) === value) {
  13211. return;
  13212. }
  13213. if (this._y.fromString(value)) {
  13214. this._multiLine._markAsDirty();
  13215. }
  13216. },
  13217. enumerable: false,
  13218. configurable: true
  13219. });
  13220. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13221. /** Gets or sets the control associated with this point */
  13222. get: function () {
  13223. return this._control;
  13224. },
  13225. set: function (value) {
  13226. if (this._control === value) {
  13227. return;
  13228. }
  13229. if (this._control && this._controlObserver) {
  13230. this._control.onDirtyObservable.remove(this._controlObserver);
  13231. this._controlObserver = null;
  13232. }
  13233. this._control = value;
  13234. if (this._control) {
  13235. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13236. }
  13237. this._multiLine._markAsDirty();
  13238. },
  13239. enumerable: false,
  13240. configurable: true
  13241. });
  13242. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13243. /** Gets or sets the mesh associated with this point */
  13244. get: function () {
  13245. return this._mesh;
  13246. },
  13247. set: function (value) {
  13248. if (this._mesh === value) {
  13249. return;
  13250. }
  13251. if (this._mesh && this._meshObserver) {
  13252. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13253. }
  13254. this._mesh = value;
  13255. if (this._mesh) {
  13256. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13257. }
  13258. this._multiLine._markAsDirty();
  13259. },
  13260. enumerable: false,
  13261. configurable: true
  13262. });
  13263. /** Resets links */
  13264. MultiLinePoint.prototype.resetLinks = function () {
  13265. this.control = null;
  13266. this.mesh = null;
  13267. };
  13268. /**
  13269. * Gets a translation vector
  13270. * @returns the translation vector
  13271. */
  13272. MultiLinePoint.prototype.translate = function () {
  13273. this._point = this._translatePoint();
  13274. return this._point;
  13275. };
  13276. MultiLinePoint.prototype._translatePoint = function () {
  13277. if (this._mesh != null) {
  13278. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13279. }
  13280. else if (this._control != null) {
  13281. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13282. }
  13283. else {
  13284. var host = this._multiLine._host;
  13285. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13286. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13287. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13288. }
  13289. };
  13290. /** Release associated resources */
  13291. MultiLinePoint.prototype.dispose = function () {
  13292. this.resetLinks();
  13293. };
  13294. return MultiLinePoint;
  13295. }());
  13296. /***/ }),
  13297. /***/ "./2D/style.ts":
  13298. /*!*********************!*\
  13299. !*** ./2D/style.ts ***!
  13300. \*********************/
  13301. /*! exports provided: Style */
  13302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13303. "use strict";
  13304. __webpack_require__.r(__webpack_exports__);
  13305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13306. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  13307. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13308. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13309. /**
  13310. * Define a style used by control to automatically setup properties based on a template.
  13311. * Only support font related properties so far
  13312. */
  13313. var Style = /** @class */ (function () {
  13314. /**
  13315. * Creates a new style object
  13316. * @param host defines the AdvancedDynamicTexture which hosts this style
  13317. */
  13318. function Style(host) {
  13319. this._fontFamily = "Arial";
  13320. this._fontStyle = "";
  13321. this._fontWeight = "";
  13322. /** @hidden */
  13323. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13324. /**
  13325. * Observable raised when the style values are changed
  13326. */
  13327. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13328. this._host = host;
  13329. }
  13330. Object.defineProperty(Style.prototype, "fontSize", {
  13331. /**
  13332. * Gets or sets the font size
  13333. */
  13334. get: function () {
  13335. return this._fontSize.toString(this._host);
  13336. },
  13337. set: function (value) {
  13338. if (this._fontSize.toString(this._host) === value) {
  13339. return;
  13340. }
  13341. if (this._fontSize.fromString(value)) {
  13342. this.onChangedObservable.notifyObservers(this);
  13343. }
  13344. },
  13345. enumerable: false,
  13346. configurable: true
  13347. });
  13348. Object.defineProperty(Style.prototype, "fontFamily", {
  13349. /**
  13350. * Gets or sets the font family
  13351. */
  13352. get: function () {
  13353. return this._fontFamily;
  13354. },
  13355. set: function (value) {
  13356. if (this._fontFamily === value) {
  13357. return;
  13358. }
  13359. this._fontFamily = value;
  13360. this.onChangedObservable.notifyObservers(this);
  13361. },
  13362. enumerable: false,
  13363. configurable: true
  13364. });
  13365. Object.defineProperty(Style.prototype, "fontStyle", {
  13366. /**
  13367. * Gets or sets the font style
  13368. */
  13369. get: function () {
  13370. return this._fontStyle;
  13371. },
  13372. set: function (value) {
  13373. if (this._fontStyle === value) {
  13374. return;
  13375. }
  13376. this._fontStyle = value;
  13377. this.onChangedObservable.notifyObservers(this);
  13378. },
  13379. enumerable: false,
  13380. configurable: true
  13381. });
  13382. Object.defineProperty(Style.prototype, "fontWeight", {
  13383. /** Gets or sets font weight */
  13384. get: function () {
  13385. return this._fontWeight;
  13386. },
  13387. set: function (value) {
  13388. if (this._fontWeight === value) {
  13389. return;
  13390. }
  13391. this._fontWeight = value;
  13392. this.onChangedObservable.notifyObservers(this);
  13393. },
  13394. enumerable: false,
  13395. configurable: true
  13396. });
  13397. /** Dispose all associated resources */
  13398. Style.prototype.dispose = function () {
  13399. this.onChangedObservable.clear();
  13400. };
  13401. return Style;
  13402. }());
  13403. /***/ }),
  13404. /***/ "./2D/valueAndUnit.ts":
  13405. /*!****************************!*\
  13406. !*** ./2D/valueAndUnit.ts ***!
  13407. \****************************/
  13408. /*! exports provided: ValueAndUnit */
  13409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13410. "use strict";
  13411. __webpack_require__.r(__webpack_exports__);
  13412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13413. /**
  13414. * Class used to specific a value and its associated unit
  13415. */
  13416. var ValueAndUnit = /** @class */ (function () {
  13417. /**
  13418. * Creates a new ValueAndUnit
  13419. * @param value defines the value to store
  13420. * @param unit defines the unit to store
  13421. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13422. */
  13423. function ValueAndUnit(value,
  13424. /** defines the unit to store */
  13425. unit,
  13426. /** defines a boolean indicating if the value can be negative */
  13427. negativeValueAllowed) {
  13428. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13429. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13430. this.unit = unit;
  13431. this.negativeValueAllowed = negativeValueAllowed;
  13432. this._value = 1;
  13433. /**
  13434. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13435. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13436. */
  13437. this.ignoreAdaptiveScaling = false;
  13438. this._value = value;
  13439. this._originalUnit = unit;
  13440. }
  13441. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13442. /** Gets a boolean indicating if the value is a percentage */
  13443. get: function () {
  13444. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13445. },
  13446. enumerable: false,
  13447. configurable: true
  13448. });
  13449. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13450. /** Gets a boolean indicating if the value is store as pixel */
  13451. get: function () {
  13452. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13453. },
  13454. enumerable: false,
  13455. configurable: true
  13456. });
  13457. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13458. /** Gets direct internal value */
  13459. get: function () {
  13460. return this._value;
  13461. },
  13462. enumerable: false,
  13463. configurable: true
  13464. });
  13465. /**
  13466. * Gets value as pixel
  13467. * @param host defines the root host
  13468. * @param refValue defines the reference value for percentages
  13469. * @returns the value as pixel
  13470. */
  13471. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13472. if (this.isPixel) {
  13473. return this.getValue(host);
  13474. }
  13475. return this.getValue(host) * refValue;
  13476. };
  13477. /**
  13478. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13479. * @param value defines the value to store
  13480. * @param unit defines the unit to store
  13481. * @returns the current ValueAndUnit
  13482. */
  13483. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13484. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13485. this._value = value;
  13486. this.unit = unit;
  13487. return this;
  13488. };
  13489. /**
  13490. * Gets the value accordingly to its unit
  13491. * @param host defines the root host
  13492. * @returns the value
  13493. */
  13494. ValueAndUnit.prototype.getValue = function (host) {
  13495. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13496. var width = 0;
  13497. var height = 0;
  13498. if (host.idealWidth) {
  13499. width = (this._value * host.getSize().width) / host.idealWidth;
  13500. }
  13501. if (host.idealHeight) {
  13502. height = (this._value * host.getSize().height) / host.idealHeight;
  13503. }
  13504. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13505. return window.innerWidth < window.innerHeight ? width : height;
  13506. }
  13507. if (host.idealWidth) { // horizontal
  13508. return width;
  13509. }
  13510. if (host.idealHeight) { // vertical
  13511. return height;
  13512. }
  13513. }
  13514. return this._value;
  13515. };
  13516. /**
  13517. * Gets a string representation of the value
  13518. * @param host defines the root host
  13519. * @param decimals defines an optional number of decimals to display
  13520. * @returns a string
  13521. */
  13522. ValueAndUnit.prototype.toString = function (host, decimals) {
  13523. switch (this.unit) {
  13524. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13525. var percentage = this.getValue(host) * 100;
  13526. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13527. case ValueAndUnit.UNITMODE_PIXEL:
  13528. var pixels = this.getValue(host);
  13529. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13530. }
  13531. return this.unit.toString();
  13532. };
  13533. /**
  13534. * Store a value parsed from a string
  13535. * @param source defines the source string
  13536. * @returns true if the value was successfully parsed
  13537. */
  13538. ValueAndUnit.prototype.fromString = function (source) {
  13539. var match = ValueAndUnit._Regex.exec(source.toString());
  13540. if (!match || match.length === 0) {
  13541. return false;
  13542. }
  13543. var sourceValue = parseFloat(match[1]);
  13544. var sourceUnit = this._originalUnit;
  13545. if (!this.negativeValueAllowed) {
  13546. if (sourceValue < 0) {
  13547. sourceValue = 0;
  13548. }
  13549. }
  13550. if (match.length === 4) {
  13551. switch (match[3]) {
  13552. case "px":
  13553. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13554. break;
  13555. case "%":
  13556. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13557. sourceValue /= 100.0;
  13558. break;
  13559. }
  13560. }
  13561. if (sourceValue === this._value && sourceUnit === this.unit) {
  13562. return false;
  13563. }
  13564. this._value = sourceValue;
  13565. this.unit = sourceUnit;
  13566. return true;
  13567. };
  13568. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13569. /** UNITMODE_PERCENTAGE */
  13570. get: function () {
  13571. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13572. },
  13573. enumerable: false,
  13574. configurable: true
  13575. });
  13576. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13577. /** UNITMODE_PIXEL */
  13578. get: function () {
  13579. return ValueAndUnit._UNITMODE_PIXEL;
  13580. },
  13581. enumerable: false,
  13582. configurable: true
  13583. });
  13584. // Static
  13585. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13586. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13587. ValueAndUnit._UNITMODE_PIXEL = 1;
  13588. return ValueAndUnit;
  13589. }());
  13590. /***/ }),
  13591. /***/ "./2D/xmlLoader.ts":
  13592. /*!*************************!*\
  13593. !*** ./2D/xmlLoader.ts ***!
  13594. \*************************/
  13595. /*! exports provided: XmlLoader */
  13596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13597. "use strict";
  13598. __webpack_require__.r(__webpack_exports__);
  13599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13600. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  13601. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13602. /**
  13603. * Class used to load GUI via XML.
  13604. */
  13605. var XmlLoader = /** @class */ (function () {
  13606. /**
  13607. * Create a new xml loader
  13608. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13609. */
  13610. function XmlLoader(parentClass) {
  13611. if (parentClass === void 0) { parentClass = null; }
  13612. this._nodes = {};
  13613. this._nodeTypes = {
  13614. element: 1,
  13615. attribute: 2,
  13616. text: 3
  13617. };
  13618. this._isLoaded = false;
  13619. this._objectAttributes = {
  13620. "textHorizontalAlignment": 1,
  13621. "textVerticalAlignment": 2,
  13622. "horizontalAlignment": 3,
  13623. "verticalAlignment": 4,
  13624. "stretch": 5,
  13625. };
  13626. if (parentClass) {
  13627. this._parentClass = parentClass;
  13628. }
  13629. }
  13630. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13631. var element = window;
  13632. if (this._parentClass) {
  13633. element = this._parentClass;
  13634. }
  13635. var value = attributeValue;
  13636. value = value.split(".");
  13637. for (var i = 0; i < value.length; i++) {
  13638. element = element[value[i]];
  13639. }
  13640. return element;
  13641. };
  13642. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13643. var attribute = attributeName.split(".");
  13644. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13645. return className[attribute[1]];
  13646. };
  13647. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13648. if (linkParent === void 0) { linkParent = true; }
  13649. try {
  13650. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13651. var guiNode = new className();
  13652. if (parent && linkParent) {
  13653. parent.addControl(guiNode);
  13654. }
  13655. for (var i = 0; i < node.attributes.length; i++) {
  13656. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13657. continue;
  13658. }
  13659. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13660. var element = this._getChainElement(node.attributes[i].value);
  13661. guiNode[node.attributes[i].name].add(element);
  13662. continue;
  13663. }
  13664. else if (node.attributes[i].name == "linkWithMesh") {
  13665. if (this._parentClass) {
  13666. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13667. }
  13668. else {
  13669. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13670. }
  13671. }
  13672. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13673. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13674. guiNode[node.attributes[i].name] = element;
  13675. }
  13676. else if (!this._objectAttributes[node.attributes[i].name]) {
  13677. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13678. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13679. }
  13680. else {
  13681. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13682. }
  13683. }
  13684. else {
  13685. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13686. }
  13687. }
  13688. if (!node.attributes.getNamedItem("id")) {
  13689. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13690. return guiNode;
  13691. }
  13692. var id = node.attributes.getNamedItem("id").value;
  13693. if (id.startsWith("{{") && id.endsWith("}}")) {
  13694. id = this._getChainElement(id.substring(2, id.length - 2));
  13695. }
  13696. if (!this._nodes[id]) {
  13697. this._nodes[id] = guiNode;
  13698. }
  13699. else {
  13700. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13701. }
  13702. return guiNode;
  13703. }
  13704. catch (e) {
  13705. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13706. }
  13707. };
  13708. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13709. var width;
  13710. var height;
  13711. var columns;
  13712. var rows = node.children;
  13713. var cells;
  13714. var isPixel = false;
  13715. var cellNode;
  13716. var rowNumber = -1;
  13717. var columnNumber = -1;
  13718. var totalColumnsNumber = 0;
  13719. for (var i = 0; i < rows.length; i++) {
  13720. if (rows[i].nodeType != this._nodeTypes.element) {
  13721. continue;
  13722. }
  13723. if (rows[i].nodeName != "Row") {
  13724. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13725. }
  13726. rowNumber += 1;
  13727. columns = rows[i].children;
  13728. if (!rows[i].attributes.getNamedItem("height")) {
  13729. throw "XmlLoader Exception : Height must be defined for grid rows";
  13730. }
  13731. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13732. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13733. guiNode.addRowDefinition(height, isPixel);
  13734. for (var j = 0; j < columns.length; j++) {
  13735. if (columns[j].nodeType != this._nodeTypes.element) {
  13736. continue;
  13737. }
  13738. if (columns[j].nodeName != "Column") {
  13739. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13740. }
  13741. columnNumber += 1;
  13742. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13743. 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.";
  13744. }
  13745. if (rowNumber == 0) {
  13746. if (!columns[j].attributes.getNamedItem("width")) {
  13747. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13748. }
  13749. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13750. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13751. guiNode.addColumnDefinition(width, isPixel);
  13752. }
  13753. cells = columns[j].children;
  13754. for (var k = 0; k < cells.length; k++) {
  13755. if (cells[k].nodeType != this._nodeTypes.element) {
  13756. continue;
  13757. }
  13758. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13759. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13760. if (cells[k].firstChild) {
  13761. this._parseXml(cells[k].firstChild, cellNode);
  13762. }
  13763. }
  13764. }
  13765. if (rowNumber == 0) {
  13766. totalColumnsNumber = columnNumber;
  13767. }
  13768. columnNumber = -1;
  13769. }
  13770. if (node.nextSibling) {
  13771. this._parseXml(node.nextSibling, parent);
  13772. }
  13773. };
  13774. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13775. if (node.firstChild) {
  13776. this._parseXml(node.firstChild, guiNode);
  13777. }
  13778. if (node.nextSibling) {
  13779. this._parseXml(node.nextSibling, parent);
  13780. }
  13781. };
  13782. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13783. if (this._parentClass) {
  13784. this._parentClass[variable] = source[iterator];
  13785. }
  13786. else {
  13787. window[variable] = source[iterator];
  13788. }
  13789. if (node.firstChild) {
  13790. this._parseXml(node.firstChild, guiNode, true);
  13791. }
  13792. };
  13793. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13794. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13795. if (!dataSource.includes(" in ")) {
  13796. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13797. }
  13798. else {
  13799. var isArray = true;
  13800. var splittedSource = dataSource.split(" in ");
  13801. if (splittedSource.length < 2) {
  13802. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13803. }
  13804. var source = splittedSource[1];
  13805. if (source.startsWith("{") && source.endsWith("}")) {
  13806. isArray = false;
  13807. }
  13808. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13809. source = source.substring(1, source.length - 1);
  13810. }
  13811. if (this._parentClass) {
  13812. source = this._parentClass[source];
  13813. }
  13814. else {
  13815. source = window[source];
  13816. }
  13817. if (isArray) {
  13818. for (var i = 0; i < source.length; i++) {
  13819. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13820. }
  13821. }
  13822. else {
  13823. for (var i in source) {
  13824. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13825. }
  13826. }
  13827. if (node.nextSibling) {
  13828. this._parseXml(node.nextSibling, parent);
  13829. }
  13830. }
  13831. };
  13832. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13833. if (generated === void 0) { generated = false; }
  13834. if (node.nodeType != this._nodeTypes.element) {
  13835. if (node.nextSibling) {
  13836. this._parseXml(node.nextSibling, parent, generated);
  13837. }
  13838. return;
  13839. }
  13840. if (generated) {
  13841. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13842. }
  13843. var guiNode = this._createGuiElement(node, parent);
  13844. if (node.nodeName == "Grid") {
  13845. this._parseGrid(node, guiNode, parent);
  13846. }
  13847. else if (!node.attributes.getNamedItem("dataSource")) {
  13848. this._parseElement(node, guiNode, parent);
  13849. }
  13850. else {
  13851. this._parseElementsFromSource(node, guiNode, parent);
  13852. }
  13853. };
  13854. /**
  13855. * Gets if the loading has finished.
  13856. * @returns whether the loading has finished or not
  13857. */
  13858. XmlLoader.prototype.isLoaded = function () {
  13859. return this._isLoaded;
  13860. };
  13861. /**
  13862. * Gets a loaded node / control by id.
  13863. * @param id the Controls id set in the xml
  13864. * @returns element of type Control
  13865. */
  13866. XmlLoader.prototype.getNodeById = function (id) {
  13867. return this._nodes[id];
  13868. };
  13869. /**
  13870. * Gets all loaded nodes / controls
  13871. * @returns Array of controls
  13872. */
  13873. XmlLoader.prototype.getNodes = function () {
  13874. return this._nodes;
  13875. };
  13876. /**
  13877. * Initiates the xml layout loading
  13878. * @param xmlFile defines the xml layout to load
  13879. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13880. * @param callback defines the callback called on layout load.
  13881. */
  13882. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13883. var xhttp = new XMLHttpRequest();
  13884. xhttp.onreadystatechange = function () {
  13885. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13886. if (!xhttp.responseXML) {
  13887. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13888. }
  13889. var xmlDoc = xhttp.responseXML.documentElement;
  13890. this._parseXml(xmlDoc.firstChild, rootNode);
  13891. this._isLoaded = true;
  13892. if (callback) {
  13893. callback();
  13894. }
  13895. }
  13896. }.bind(this);
  13897. xhttp.open("GET", xmlFile, true);
  13898. xhttp.send();
  13899. };
  13900. return XmlLoader;
  13901. }());
  13902. /***/ }),
  13903. /***/ "./3D/controls/abstractButton3D.ts":
  13904. /*!*****************************************!*\
  13905. !*** ./3D/controls/abstractButton3D.ts ***!
  13906. \*****************************************/
  13907. /*! exports provided: AbstractButton3D */
  13908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13909. "use strict";
  13910. __webpack_require__.r(__webpack_exports__);
  13911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13912. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13913. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  13914. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13915. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13916. /**
  13917. * Class used as a root to all buttons
  13918. */
  13919. var AbstractButton3D = /** @class */ (function (_super) {
  13920. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13921. /**
  13922. * Creates a new button
  13923. * @param name defines the control name
  13924. */
  13925. function AbstractButton3D(name) {
  13926. return _super.call(this, name) || this;
  13927. }
  13928. AbstractButton3D.prototype._getTypeName = function () {
  13929. return "AbstractButton3D";
  13930. };
  13931. // Mesh association
  13932. AbstractButton3D.prototype._createNode = function (scene) {
  13933. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13934. };
  13935. return AbstractButton3D;
  13936. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13937. /***/ }),
  13938. /***/ "./3D/controls/button3D.ts":
  13939. /*!*********************************!*\
  13940. !*** ./3D/controls/button3D.ts ***!
  13941. \*********************************/
  13942. /*! exports provided: Button3D */
  13943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13944. "use strict";
  13945. __webpack_require__.r(__webpack_exports__);
  13946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13947. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13948. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13949. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13950. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13951. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13952. /**
  13953. * Class used to create a button in 3D
  13954. */
  13955. var Button3D = /** @class */ (function (_super) {
  13956. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13957. /**
  13958. * Creates a new button
  13959. * @param name defines the control name
  13960. */
  13961. function Button3D(name) {
  13962. var _this = _super.call(this, name) || this;
  13963. _this._contentResolution = 512;
  13964. _this._contentScaleRatio = 2;
  13965. // Default animations
  13966. _this.pointerEnterAnimation = function () {
  13967. if (!_this.mesh) {
  13968. return;
  13969. }
  13970. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13971. };
  13972. _this.pointerOutAnimation = function () {
  13973. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13974. };
  13975. _this.pointerDownAnimation = function () {
  13976. if (!_this.mesh) {
  13977. return;
  13978. }
  13979. _this.mesh.scaling.scaleInPlace(0.95);
  13980. };
  13981. _this.pointerUpAnimation = function () {
  13982. if (!_this.mesh) {
  13983. return;
  13984. }
  13985. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13986. };
  13987. return _this;
  13988. }
  13989. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13990. /**
  13991. * Gets or sets the texture resolution used to render content (512 by default)
  13992. */
  13993. get: function () {
  13994. return this._contentResolution;
  13995. },
  13996. set: function (value) {
  13997. if (this._contentResolution === value) {
  13998. return;
  13999. }
  14000. this._contentResolution = value;
  14001. this._resetContent();
  14002. },
  14003. enumerable: false,
  14004. configurable: true
  14005. });
  14006. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  14007. /**
  14008. * Gets or sets the texture scale ratio used to render content (2 by default)
  14009. */
  14010. get: function () {
  14011. return this._contentScaleRatio;
  14012. },
  14013. set: function (value) {
  14014. if (this._contentScaleRatio === value) {
  14015. return;
  14016. }
  14017. this._contentScaleRatio = value;
  14018. this._resetContent();
  14019. },
  14020. enumerable: false,
  14021. configurable: true
  14022. });
  14023. Button3D.prototype._disposeFacadeTexture = function () {
  14024. if (this._facadeTexture) {
  14025. this._facadeTexture.dispose();
  14026. this._facadeTexture = null;
  14027. }
  14028. };
  14029. Button3D.prototype._resetContent = function () {
  14030. this._disposeFacadeTexture();
  14031. this.content = this._content;
  14032. };
  14033. Object.defineProperty(Button3D.prototype, "content", {
  14034. /**
  14035. * Gets or sets the GUI 2D content used to display the button's facade
  14036. */
  14037. get: function () {
  14038. return this._content;
  14039. },
  14040. set: function (value) {
  14041. this._content = value;
  14042. if (!this._host || !this._host.utilityLayer) {
  14043. return;
  14044. }
  14045. if (!this._facadeTexture) {
  14046. 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);
  14047. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  14048. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  14049. this._facadeTexture.premulAlpha = true;
  14050. }
  14051. else {
  14052. this._facadeTexture.rootContainer.clearControls();
  14053. }
  14054. this._facadeTexture.addControl(value);
  14055. this._applyFacade(this._facadeTexture);
  14056. },
  14057. enumerable: false,
  14058. configurable: true
  14059. });
  14060. /**
  14061. * Apply the facade texture (created from the content property).
  14062. * This function can be overloaded by child classes
  14063. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14064. */
  14065. Button3D.prototype._applyFacade = function (facadeTexture) {
  14066. this._currentMaterial.emissiveTexture = facadeTexture;
  14067. };
  14068. Button3D.prototype._getTypeName = function () {
  14069. return "Button3D";
  14070. };
  14071. // Mesh association
  14072. Button3D.prototype._createNode = function (scene) {
  14073. var faceUV = new Array(6);
  14074. for (var i = 0; i < 6; i++) {
  14075. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14076. }
  14077. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14078. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14079. width: 1.0,
  14080. height: 1.0,
  14081. depth: 0.08,
  14082. faceUV: faceUV
  14083. }, scene);
  14084. return mesh;
  14085. };
  14086. Button3D.prototype._affectMaterial = function (mesh) {
  14087. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14088. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14089. mesh.material = material;
  14090. this._currentMaterial = material;
  14091. this._resetContent();
  14092. };
  14093. /**
  14094. * Releases all associated resources
  14095. */
  14096. Button3D.prototype.dispose = function () {
  14097. _super.prototype.dispose.call(this);
  14098. this._disposeFacadeTexture();
  14099. if (this._currentMaterial) {
  14100. this._currentMaterial.dispose();
  14101. }
  14102. };
  14103. return Button3D;
  14104. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14105. /***/ }),
  14106. /***/ "./3D/controls/container3D.ts":
  14107. /*!************************************!*\
  14108. !*** ./3D/controls/container3D.ts ***!
  14109. \************************************/
  14110. /*! exports provided: Container3D */
  14111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14112. "use strict";
  14113. __webpack_require__.r(__webpack_exports__);
  14114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14115. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14116. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  14117. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14118. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14119. /**
  14120. * Class used to create containers for controls
  14121. */
  14122. var Container3D = /** @class */ (function (_super) {
  14123. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14124. /**
  14125. * Creates a new container
  14126. * @param name defines the container name
  14127. */
  14128. function Container3D(name) {
  14129. var _this = _super.call(this, name) || this;
  14130. _this._blockLayout = false;
  14131. /**
  14132. * Gets the list of child controls
  14133. */
  14134. _this._children = new Array();
  14135. return _this;
  14136. }
  14137. Object.defineProperty(Container3D.prototype, "children", {
  14138. /**
  14139. * Gets the list of child controls
  14140. */
  14141. get: function () {
  14142. return this._children;
  14143. },
  14144. enumerable: false,
  14145. configurable: true
  14146. });
  14147. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14148. /**
  14149. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14150. * This is helpful to optimize layout operation when adding multiple children in a row
  14151. */
  14152. get: function () {
  14153. return this._blockLayout;
  14154. },
  14155. set: function (value) {
  14156. if (this._blockLayout === value) {
  14157. return;
  14158. }
  14159. this._blockLayout = value;
  14160. if (!this._blockLayout) {
  14161. this._arrangeChildren();
  14162. }
  14163. },
  14164. enumerable: false,
  14165. configurable: true
  14166. });
  14167. /**
  14168. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14169. * @returns the current container
  14170. */
  14171. Container3D.prototype.updateLayout = function () {
  14172. this._arrangeChildren();
  14173. return this;
  14174. };
  14175. /**
  14176. * Gets a boolean indicating if the given control is in the children of this control
  14177. * @param control defines the control to check
  14178. * @returns true if the control is in the child list
  14179. */
  14180. Container3D.prototype.containsControl = function (control) {
  14181. return this._children.indexOf(control) !== -1;
  14182. };
  14183. /**
  14184. * Adds a control to the children of this control
  14185. * @param control defines the control to add
  14186. * @returns the current container
  14187. */
  14188. Container3D.prototype.addControl = function (control) {
  14189. var index = this._children.indexOf(control);
  14190. if (index !== -1) {
  14191. return this;
  14192. }
  14193. control.parent = this;
  14194. control._host = this._host;
  14195. this._children.push(control);
  14196. if (this._host.utilityLayer) {
  14197. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14198. if (control.node) {
  14199. control.node.parent = this.node;
  14200. }
  14201. if (!this.blockLayout) {
  14202. this._arrangeChildren();
  14203. }
  14204. }
  14205. return this;
  14206. };
  14207. /**
  14208. * This function will be called everytime a new control is added
  14209. */
  14210. Container3D.prototype._arrangeChildren = function () {
  14211. };
  14212. Container3D.prototype._createNode = function (scene) {
  14213. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14214. };
  14215. /**
  14216. * Removes a control from the children of this control
  14217. * @param control defines the control to remove
  14218. * @returns the current container
  14219. */
  14220. Container3D.prototype.removeControl = function (control) {
  14221. var index = this._children.indexOf(control);
  14222. if (index !== -1) {
  14223. this._children.splice(index, 1);
  14224. control.parent = null;
  14225. control._disposeNode();
  14226. }
  14227. return this;
  14228. };
  14229. Container3D.prototype._getTypeName = function () {
  14230. return "Container3D";
  14231. };
  14232. /**
  14233. * Releases all associated resources
  14234. */
  14235. Container3D.prototype.dispose = function () {
  14236. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14237. var control = _a[_i];
  14238. control.dispose();
  14239. }
  14240. this._children = [];
  14241. _super.prototype.dispose.call(this);
  14242. };
  14243. /** Control rotation will remain unchanged */
  14244. Container3D.UNSET_ORIENTATION = 0;
  14245. /** Control will rotate to make it look at sphere central axis */
  14246. Container3D.FACEORIGIN_ORIENTATION = 1;
  14247. /** Control will rotate to make it look back at sphere central axis */
  14248. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14249. /** Control will rotate to look at z axis (0, 0, 1) */
  14250. Container3D.FACEFORWARD_ORIENTATION = 3;
  14251. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14252. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14253. return Container3D;
  14254. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14255. /***/ }),
  14256. /***/ "./3D/controls/control3D.ts":
  14257. /*!**********************************!*\
  14258. !*** ./3D/controls/control3D.ts ***!
  14259. \**********************************/
  14260. /*! exports provided: Control3D */
  14261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14262. "use strict";
  14263. __webpack_require__.r(__webpack_exports__);
  14264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14265. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  14266. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14267. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14268. /**
  14269. * Class used as base class for controls
  14270. */
  14271. var Control3D = /** @class */ (function () {
  14272. /**
  14273. * Creates a new control
  14274. * @param name defines the control name
  14275. */
  14276. function Control3D(
  14277. /** Defines the control name */
  14278. name) {
  14279. this.name = name;
  14280. this._downCount = 0;
  14281. this._enterCount = -1;
  14282. this._downPointerIds = {};
  14283. this._isVisible = true;
  14284. /**
  14285. * An event triggered when the pointer move over the control
  14286. */
  14287. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14288. /**
  14289. * An event triggered when the pointer move out of the control
  14290. */
  14291. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14292. /**
  14293. * An event triggered when the pointer taps the control
  14294. */
  14295. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14296. /**
  14297. * An event triggered when pointer is up
  14298. */
  14299. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14300. /**
  14301. * An event triggered when a control is clicked on (with a mouse)
  14302. */
  14303. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14304. /**
  14305. * An event triggered when pointer enters the control
  14306. */
  14307. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14308. // Behaviors
  14309. this._behaviors = new Array();
  14310. }
  14311. Object.defineProperty(Control3D.prototype, "position", {
  14312. /** Gets or sets the control position in world space */
  14313. get: function () {
  14314. if (!this._node) {
  14315. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14316. }
  14317. return this._node.position;
  14318. },
  14319. set: function (value) {
  14320. if (!this._node) {
  14321. return;
  14322. }
  14323. this._node.position = value;
  14324. },
  14325. enumerable: false,
  14326. configurable: true
  14327. });
  14328. Object.defineProperty(Control3D.prototype, "scaling", {
  14329. /** Gets or sets the control scaling in world space */
  14330. get: function () {
  14331. if (!this._node) {
  14332. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14333. }
  14334. return this._node.scaling;
  14335. },
  14336. set: function (value) {
  14337. if (!this._node) {
  14338. return;
  14339. }
  14340. this._node.scaling = value;
  14341. },
  14342. enumerable: false,
  14343. configurable: true
  14344. });
  14345. Object.defineProperty(Control3D.prototype, "behaviors", {
  14346. /**
  14347. * Gets the list of attached behaviors
  14348. * @see https://doc.babylonjs.com/features/behaviour
  14349. */
  14350. get: function () {
  14351. return this._behaviors;
  14352. },
  14353. enumerable: false,
  14354. configurable: true
  14355. });
  14356. /**
  14357. * Attach a behavior to the control
  14358. * @see https://doc.babylonjs.com/features/behaviour
  14359. * @param behavior defines the behavior to attach
  14360. * @returns the current control
  14361. */
  14362. Control3D.prototype.addBehavior = function (behavior) {
  14363. var _this = this;
  14364. var index = this._behaviors.indexOf(behavior);
  14365. if (index !== -1) {
  14366. return this;
  14367. }
  14368. behavior.init();
  14369. var scene = this._host.scene;
  14370. if (scene.isLoading) {
  14371. // We defer the attach when the scene will be loaded
  14372. scene.onDataLoadedObservable.addOnce(function () {
  14373. behavior.attach(_this);
  14374. });
  14375. }
  14376. else {
  14377. behavior.attach(this);
  14378. }
  14379. this._behaviors.push(behavior);
  14380. return this;
  14381. };
  14382. /**
  14383. * Remove an attached behavior
  14384. * @see https://doc.babylonjs.com/features/behaviour
  14385. * @param behavior defines the behavior to attach
  14386. * @returns the current control
  14387. */
  14388. Control3D.prototype.removeBehavior = function (behavior) {
  14389. var index = this._behaviors.indexOf(behavior);
  14390. if (index === -1) {
  14391. return this;
  14392. }
  14393. this._behaviors[index].detach();
  14394. this._behaviors.splice(index, 1);
  14395. return this;
  14396. };
  14397. /**
  14398. * Gets an attached behavior by name
  14399. * @param name defines the name of the behavior to look for
  14400. * @see https://doc.babylonjs.com/features/behaviour
  14401. * @returns null if behavior was not found else the requested behavior
  14402. */
  14403. Control3D.prototype.getBehaviorByName = function (name) {
  14404. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14405. var behavior = _a[_i];
  14406. if (behavior.name === name) {
  14407. return behavior;
  14408. }
  14409. }
  14410. return null;
  14411. };
  14412. Object.defineProperty(Control3D.prototype, "isVisible", {
  14413. /** Gets or sets a boolean indicating if the control is visible */
  14414. get: function () {
  14415. return this._isVisible;
  14416. },
  14417. set: function (value) {
  14418. if (this._isVisible === value) {
  14419. return;
  14420. }
  14421. this._isVisible = value;
  14422. var mesh = this.mesh;
  14423. if (mesh) {
  14424. mesh.setEnabled(value);
  14425. }
  14426. },
  14427. enumerable: false,
  14428. configurable: true
  14429. });
  14430. Object.defineProperty(Control3D.prototype, "typeName", {
  14431. /**
  14432. * Gets a string representing the class name
  14433. */
  14434. get: function () {
  14435. return this._getTypeName();
  14436. },
  14437. enumerable: false,
  14438. configurable: true
  14439. });
  14440. /**
  14441. * Get the current class name of the control.
  14442. * @returns current class name
  14443. */
  14444. Control3D.prototype.getClassName = function () {
  14445. return this._getTypeName();
  14446. };
  14447. Control3D.prototype._getTypeName = function () {
  14448. return "Control3D";
  14449. };
  14450. Object.defineProperty(Control3D.prototype, "node", {
  14451. /**
  14452. * Gets the transform node used by this control
  14453. */
  14454. get: function () {
  14455. return this._node;
  14456. },
  14457. enumerable: false,
  14458. configurable: true
  14459. });
  14460. Object.defineProperty(Control3D.prototype, "mesh", {
  14461. /**
  14462. * Gets the mesh used to render this control
  14463. */
  14464. get: function () {
  14465. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14466. return this._node;
  14467. }
  14468. return null;
  14469. },
  14470. enumerable: false,
  14471. configurable: true
  14472. });
  14473. /**
  14474. * Link the control as child of the given node
  14475. * @param node defines the node to link to. Use null to unlink the control
  14476. * @returns the current control
  14477. */
  14478. Control3D.prototype.linkToTransformNode = function (node) {
  14479. if (this._node) {
  14480. this._node.parent = node;
  14481. }
  14482. return this;
  14483. };
  14484. /** @hidden **/
  14485. Control3D.prototype._prepareNode = function (scene) {
  14486. if (!this._node) {
  14487. this._node = this._createNode(scene);
  14488. if (!this.node) {
  14489. return;
  14490. }
  14491. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14492. this._node.position = this.position;
  14493. this._node.scaling = this.scaling;
  14494. var mesh = this.mesh;
  14495. if (mesh) {
  14496. mesh.isPickable = true;
  14497. this._affectMaterial(mesh);
  14498. }
  14499. }
  14500. };
  14501. /**
  14502. * Node creation.
  14503. * Can be overriden by children
  14504. * @param scene defines the scene where the node must be attached
  14505. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14506. */
  14507. Control3D.prototype._createNode = function (scene) {
  14508. // Do nothing by default
  14509. return null;
  14510. };
  14511. /**
  14512. * Affect a material to the given mesh
  14513. * @param mesh defines the mesh which will represent the control
  14514. */
  14515. Control3D.prototype._affectMaterial = function (mesh) {
  14516. mesh.material = null;
  14517. };
  14518. // Pointers
  14519. /** @hidden */
  14520. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14521. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14522. };
  14523. /** @hidden */
  14524. Control3D.prototype._onPointerEnter = function (target) {
  14525. if (this._enterCount > 0) {
  14526. return false;
  14527. }
  14528. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14529. this._enterCount = 0;
  14530. }
  14531. this._enterCount++;
  14532. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14533. if (this.pointerEnterAnimation) {
  14534. this.pointerEnterAnimation();
  14535. }
  14536. return true;
  14537. };
  14538. /** @hidden */
  14539. Control3D.prototype._onPointerOut = function (target) {
  14540. this._enterCount = 0;
  14541. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14542. if (this.pointerOutAnimation) {
  14543. this.pointerOutAnimation();
  14544. }
  14545. };
  14546. /** @hidden */
  14547. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14548. if (this._downCount !== 0) {
  14549. this._downCount++;
  14550. return false;
  14551. }
  14552. this._downCount++;
  14553. this._downPointerIds[pointerId] = true;
  14554. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14555. if (this.pointerDownAnimation) {
  14556. this.pointerDownAnimation();
  14557. }
  14558. return true;
  14559. };
  14560. /** @hidden */
  14561. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14562. this._downCount--;
  14563. delete this._downPointerIds[pointerId];
  14564. if (this._downCount < 0) {
  14565. // Handle if forcePointerUp was called prior to this
  14566. this._downCount = 0;
  14567. return;
  14568. }
  14569. if (this._downCount == 0) {
  14570. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14571. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14572. }
  14573. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14574. if (this.pointerUpAnimation) {
  14575. this.pointerUpAnimation();
  14576. }
  14577. }
  14578. };
  14579. /** @hidden */
  14580. Control3D.prototype.forcePointerUp = function (pointerId) {
  14581. if (pointerId === void 0) { pointerId = null; }
  14582. if (pointerId !== null) {
  14583. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14584. }
  14585. else {
  14586. for (var key in this._downPointerIds) {
  14587. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14588. }
  14589. if (this._downCount > 0) {
  14590. this._downCount = 1;
  14591. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14592. }
  14593. }
  14594. };
  14595. /** @hidden */
  14596. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14597. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14598. this._onPointerMove(this, pickedPoint);
  14599. var previousControlOver = this._host._lastControlOver[pointerId];
  14600. if (previousControlOver && previousControlOver !== this) {
  14601. previousControlOver._onPointerOut(this);
  14602. }
  14603. if (previousControlOver !== this) {
  14604. this._onPointerEnter(this);
  14605. }
  14606. this._host._lastControlOver[pointerId] = this;
  14607. return true;
  14608. }
  14609. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14610. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14611. this._host._lastControlDown[pointerId] = this;
  14612. this._host._lastPickedControl = this;
  14613. return true;
  14614. }
  14615. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  14616. if (this._host._lastControlDown[pointerId]) {
  14617. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14618. }
  14619. delete this._host._lastControlDown[pointerId];
  14620. return true;
  14621. }
  14622. return false;
  14623. };
  14624. /** @hidden */
  14625. Control3D.prototype._disposeNode = function () {
  14626. if (this._node) {
  14627. this._node.dispose();
  14628. this._node = null;
  14629. }
  14630. };
  14631. /**
  14632. * Releases all associated resources
  14633. */
  14634. Control3D.prototype.dispose = function () {
  14635. this.onPointerDownObservable.clear();
  14636. this.onPointerEnterObservable.clear();
  14637. this.onPointerMoveObservable.clear();
  14638. this.onPointerOutObservable.clear();
  14639. this.onPointerUpObservable.clear();
  14640. this.onPointerClickObservable.clear();
  14641. this._disposeNode();
  14642. // Behaviors
  14643. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14644. var behavior = _a[_i];
  14645. behavior.detach();
  14646. }
  14647. };
  14648. return Control3D;
  14649. }());
  14650. /***/ }),
  14651. /***/ "./3D/controls/cylinderPanel.ts":
  14652. /*!**************************************!*\
  14653. !*** ./3D/controls/cylinderPanel.ts ***!
  14654. \**************************************/
  14655. /*! exports provided: CylinderPanel */
  14656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14657. "use strict";
  14658. __webpack_require__.r(__webpack_exports__);
  14659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14660. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14661. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  14662. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14663. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14664. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14665. /**
  14666. * Class used to create a container panel deployed on the surface of a cylinder
  14667. */
  14668. var CylinderPanel = /** @class */ (function (_super) {
  14669. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14670. function CylinderPanel() {
  14671. var _this = _super !== null && _super.apply(this, arguments) || this;
  14672. _this._radius = 5.0;
  14673. return _this;
  14674. }
  14675. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14676. /**
  14677. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14678. */
  14679. get: function () {
  14680. return this._radius;
  14681. },
  14682. set: function (value) {
  14683. var _this = this;
  14684. if (this._radius === value) {
  14685. return;
  14686. }
  14687. this._radius = value;
  14688. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14689. _this._arrangeChildren();
  14690. });
  14691. },
  14692. enumerable: false,
  14693. configurable: true
  14694. });
  14695. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14696. var mesh = control.mesh;
  14697. if (!mesh) {
  14698. return;
  14699. }
  14700. var newPos = this._cylindricalMapping(nodePosition);
  14701. control.position = newPos;
  14702. switch (this.orientation) {
  14703. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14704. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14705. break;
  14706. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14707. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14708. break;
  14709. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14710. break;
  14711. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14712. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14713. break;
  14714. }
  14715. };
  14716. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14717. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14718. var yAngle = (source.x / this._radius);
  14719. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14720. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14721. };
  14722. return CylinderPanel;
  14723. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14724. /***/ }),
  14725. /***/ "./3D/controls/holographicButton.ts":
  14726. /*!******************************************!*\
  14727. !*** ./3D/controls/holographicButton.ts ***!
  14728. \******************************************/
  14729. /*! exports provided: HolographicButton */
  14730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14731. "use strict";
  14732. __webpack_require__.r(__webpack_exports__);
  14733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14735. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14736. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Maths/math.vector");
  14737. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14738. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14739. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14740. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14741. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14742. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14743. /**
  14744. * Class used to create a holographic button in 3D
  14745. */
  14746. var HolographicButton = /** @class */ (function (_super) {
  14747. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14748. /**
  14749. * Creates a new button
  14750. * @param name defines the control name
  14751. */
  14752. function HolographicButton(name, shareMaterials) {
  14753. if (shareMaterials === void 0) { shareMaterials = true; }
  14754. var _this = _super.call(this, name) || this;
  14755. _this._shareMaterials = true;
  14756. _this._shareMaterials = shareMaterials;
  14757. // Default animations
  14758. _this.pointerEnterAnimation = function () {
  14759. if (!_this.mesh) {
  14760. return;
  14761. }
  14762. _this._frontPlate.setEnabled(true);
  14763. };
  14764. _this.pointerOutAnimation = function () {
  14765. if (!_this.mesh) {
  14766. return;
  14767. }
  14768. _this._frontPlate.setEnabled(false);
  14769. };
  14770. return _this;
  14771. }
  14772. HolographicButton.prototype._disposeTooltip = function () {
  14773. this._tooltipFade = null;
  14774. if (this._tooltipTextBlock) {
  14775. this._tooltipTextBlock.dispose();
  14776. }
  14777. if (this._tooltipTexture) {
  14778. this._tooltipTexture.dispose();
  14779. }
  14780. if (this._tooltipMesh) {
  14781. this._tooltipMesh.dispose();
  14782. }
  14783. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14784. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14785. };
  14786. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14787. get: function () {
  14788. return this._backPlate.renderingGroupId;
  14789. },
  14790. /**
  14791. * Rendering ground id of all the mesh in the button
  14792. */
  14793. set: function (id) {
  14794. this._backPlate.renderingGroupId = id;
  14795. this._textPlate.renderingGroupId = id;
  14796. this._frontPlate.renderingGroupId = id;
  14797. if (this._tooltipMesh) {
  14798. this._tooltipMesh.renderingGroupId = id;
  14799. }
  14800. },
  14801. enumerable: false,
  14802. configurable: true
  14803. });
  14804. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14805. get: function () {
  14806. if (this._tooltipTextBlock) {
  14807. return this._tooltipTextBlock.text;
  14808. }
  14809. return null;
  14810. },
  14811. /**
  14812. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14813. */
  14814. set: function (text) {
  14815. var _this = this;
  14816. if (!text) {
  14817. this._disposeTooltip();
  14818. return;
  14819. }
  14820. if (!this._tooltipFade) {
  14821. // Create tooltip with mesh and text
  14822. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14823. 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);
  14824. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14825. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14826. tooltipBackground.material = mat;
  14827. tooltipBackground.isPickable = false;
  14828. this._tooltipMesh.addChild(tooltipBackground);
  14829. tooltipBackground.position.z = 0.05;
  14830. this._tooltipMesh.scaling.y = 1 / 3;
  14831. this._tooltipMesh.position.y = 0.7;
  14832. this._tooltipMesh.position.z = -0.15;
  14833. this._tooltipMesh.isPickable = false;
  14834. this._tooltipMesh.parent = this._backPlate;
  14835. // Create text texture for the tooltip
  14836. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14837. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14838. this._tooltipTextBlock.scaleY = 3;
  14839. this._tooltipTextBlock.color = "white";
  14840. this._tooltipTextBlock.fontSize = 130;
  14841. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14842. // Add hover action to tooltip
  14843. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14844. this._tooltipFade.delay = 500;
  14845. this._tooltipMesh.addBehavior(this._tooltipFade);
  14846. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14847. if (_this._tooltipFade) {
  14848. _this._tooltipFade.fadeIn(true);
  14849. }
  14850. });
  14851. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14852. if (_this._tooltipFade) {
  14853. _this._tooltipFade.fadeIn(false);
  14854. }
  14855. });
  14856. }
  14857. if (this._tooltipTextBlock) {
  14858. this._tooltipTextBlock.text = text;
  14859. }
  14860. },
  14861. enumerable: false,
  14862. configurable: true
  14863. });
  14864. Object.defineProperty(HolographicButton.prototype, "text", {
  14865. /**
  14866. * Gets or sets text for the button
  14867. */
  14868. get: function () {
  14869. return this._text;
  14870. },
  14871. set: function (value) {
  14872. if (this._text === value) {
  14873. return;
  14874. }
  14875. this._text = value;
  14876. this._rebuildContent();
  14877. },
  14878. enumerable: false,
  14879. configurable: true
  14880. });
  14881. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14882. /**
  14883. * Gets or sets the image url for the button
  14884. */
  14885. get: function () {
  14886. return this._imageUrl;
  14887. },
  14888. set: function (value) {
  14889. if (this._imageUrl === value) {
  14890. return;
  14891. }
  14892. this._imageUrl = value;
  14893. this._rebuildContent();
  14894. },
  14895. enumerable: false,
  14896. configurable: true
  14897. });
  14898. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14899. /**
  14900. * Gets the back material used by this button
  14901. */
  14902. get: function () {
  14903. return this._backMaterial;
  14904. },
  14905. enumerable: false,
  14906. configurable: true
  14907. });
  14908. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14909. /**
  14910. * Gets the front material used by this button
  14911. */
  14912. get: function () {
  14913. return this._frontMaterial;
  14914. },
  14915. enumerable: false,
  14916. configurable: true
  14917. });
  14918. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14919. /**
  14920. * Gets the plate material used by this button
  14921. */
  14922. get: function () {
  14923. return this._plateMaterial;
  14924. },
  14925. enumerable: false,
  14926. configurable: true
  14927. });
  14928. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14929. /**
  14930. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14931. */
  14932. get: function () {
  14933. return this._shareMaterials;
  14934. },
  14935. enumerable: false,
  14936. configurable: true
  14937. });
  14938. HolographicButton.prototype._getTypeName = function () {
  14939. return "HolographicButton";
  14940. };
  14941. HolographicButton.prototype._rebuildContent = function () {
  14942. this._disposeFacadeTexture();
  14943. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14944. panel.isVertical = true;
  14945. if (this._imageUrl) {
  14946. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14947. image.source = this._imageUrl;
  14948. image.paddingTop = "40px";
  14949. image.height = "180px";
  14950. image.width = "100px";
  14951. image.paddingBottom = "40px";
  14952. panel.addControl(image);
  14953. }
  14954. if (this._text) {
  14955. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14956. text.text = this._text;
  14957. text.color = "white";
  14958. text.height = "30px";
  14959. text.fontSize = 24;
  14960. panel.addControl(text);
  14961. }
  14962. if (this._frontPlate) {
  14963. this.content = panel;
  14964. }
  14965. };
  14966. // Mesh association
  14967. HolographicButton.prototype._createNode = function (scene) {
  14968. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14969. width: 1.0,
  14970. height: 1.0,
  14971. depth: 0.08
  14972. }, scene);
  14973. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14974. width: 1.0,
  14975. height: 1.0,
  14976. depth: 0.08
  14977. }, scene);
  14978. this._frontPlate.parent = this._backPlate;
  14979. this._frontPlate.position.z = -0.08;
  14980. this._frontPlate.isPickable = false;
  14981. this._frontPlate.setEnabled(false);
  14982. this._textPlate = _super.prototype._createNode.call(this, scene);
  14983. this._textPlate.parent = this._backPlate;
  14984. this._textPlate.position.z = -0.08;
  14985. this._textPlate.isPickable = false;
  14986. return this._backPlate;
  14987. };
  14988. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14989. this._plateMaterial.emissiveTexture = facadeTexture;
  14990. this._plateMaterial.opacityTexture = facadeTexture;
  14991. };
  14992. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14993. var _this = this;
  14994. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14995. this._backMaterial.renderHoverLight = true;
  14996. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14997. if (pickedPoint) {
  14998. _this._backMaterial.hoverPosition = pickedPoint;
  14999. _this._backMaterial.hoverColor.a = 1.0;
  15000. }
  15001. else {
  15002. _this._backMaterial.hoverColor.a = 0;
  15003. }
  15004. });
  15005. };
  15006. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  15007. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  15008. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  15009. this._frontMaterial.alpha = 0.5; // Additive
  15010. this._frontMaterial.renderBorders = true;
  15011. };
  15012. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  15013. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  15014. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  15015. };
  15016. HolographicButton.prototype._affectMaterial = function (mesh) {
  15017. // Back
  15018. if (this._shareMaterials) {
  15019. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  15020. this._createBackMaterial(mesh);
  15021. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  15022. }
  15023. else {
  15024. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  15025. }
  15026. // Front
  15027. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  15028. this._createFrontMaterial(mesh);
  15029. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  15030. }
  15031. else {
  15032. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  15033. }
  15034. }
  15035. else {
  15036. this._createBackMaterial(mesh);
  15037. this._createFrontMaterial(mesh);
  15038. }
  15039. this._createPlateMaterial(mesh);
  15040. this._backPlate.material = this._backMaterial;
  15041. this._frontPlate.material = this._frontMaterial;
  15042. this._textPlate.material = this._plateMaterial;
  15043. this._rebuildContent();
  15044. };
  15045. /**
  15046. * Releases all associated resources
  15047. */
  15048. HolographicButton.prototype.dispose = function () {
  15049. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  15050. this._disposeTooltip();
  15051. if (!this.shareMaterials) {
  15052. this._backMaterial.dispose();
  15053. this._frontMaterial.dispose();
  15054. this._plateMaterial.dispose();
  15055. if (this._pickedPointObserver) {
  15056. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  15057. this._pickedPointObserver = null;
  15058. }
  15059. }
  15060. };
  15061. return HolographicButton;
  15062. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15063. /***/ }),
  15064. /***/ "./3D/controls/index.ts":
  15065. /*!******************************!*\
  15066. !*** ./3D/controls/index.ts ***!
  15067. \******************************/
  15068. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15070. "use strict";
  15071. __webpack_require__.r(__webpack_exports__);
  15072. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15074. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15076. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15078. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15080. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15082. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15084. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15086. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15088. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15090. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15092. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15094. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15096. /***/ }),
  15097. /***/ "./3D/controls/meshButton3D.ts":
  15098. /*!*************************************!*\
  15099. !*** ./3D/controls/meshButton3D.ts ***!
  15100. \*************************************/
  15101. /*! exports provided: MeshButton3D */
  15102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15103. "use strict";
  15104. __webpack_require__.r(__webpack_exports__);
  15105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15106. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15107. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15108. /**
  15109. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15110. */
  15111. var MeshButton3D = /** @class */ (function (_super) {
  15112. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15113. /**
  15114. * Creates a new 3D button based on a mesh
  15115. * @param mesh mesh to become a 3D button
  15116. * @param name defines the control name
  15117. */
  15118. function MeshButton3D(mesh, name) {
  15119. var _this = _super.call(this, name) || this;
  15120. _this._currentMesh = mesh;
  15121. /**
  15122. * Provides a default behavior on hover/out & up/down
  15123. * Override those function to create your own desired behavior specific to your mesh
  15124. */
  15125. _this.pointerEnterAnimation = function () {
  15126. if (!_this.mesh) {
  15127. return;
  15128. }
  15129. _this.mesh.scaling.scaleInPlace(1.1);
  15130. };
  15131. _this.pointerOutAnimation = function () {
  15132. if (!_this.mesh) {
  15133. return;
  15134. }
  15135. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15136. };
  15137. _this.pointerDownAnimation = function () {
  15138. if (!_this.mesh) {
  15139. return;
  15140. }
  15141. _this.mesh.scaling.scaleInPlace(0.95);
  15142. };
  15143. _this.pointerUpAnimation = function () {
  15144. if (!_this.mesh) {
  15145. return;
  15146. }
  15147. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15148. };
  15149. return _this;
  15150. }
  15151. MeshButton3D.prototype._getTypeName = function () {
  15152. return "MeshButton3D";
  15153. };
  15154. // Mesh association
  15155. MeshButton3D.prototype._createNode = function (scene) {
  15156. var _this = this;
  15157. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15158. mesh.metadata = _this;
  15159. });
  15160. return this._currentMesh;
  15161. };
  15162. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15163. };
  15164. return MeshButton3D;
  15165. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15166. /***/ }),
  15167. /***/ "./3D/controls/planePanel.ts":
  15168. /*!***********************************!*\
  15169. !*** ./3D/controls/planePanel.ts ***!
  15170. \***********************************/
  15171. /*! exports provided: PlanePanel */
  15172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15173. "use strict";
  15174. __webpack_require__.r(__webpack_exports__);
  15175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15177. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  15178. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15179. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15180. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15181. /**
  15182. * Class used to create a container panel deployed on the surface of a plane
  15183. */
  15184. var PlanePanel = /** @class */ (function (_super) {
  15185. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15186. function PlanePanel() {
  15187. return _super !== null && _super.apply(this, arguments) || this;
  15188. }
  15189. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15190. var mesh = control.mesh;
  15191. if (!mesh) {
  15192. return;
  15193. }
  15194. control.position = nodePosition.clone();
  15195. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15196. target.copyFrom(nodePosition);
  15197. switch (this.orientation) {
  15198. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15199. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15200. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15201. mesh.lookAt(target);
  15202. break;
  15203. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15204. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15205. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15206. mesh.lookAt(target);
  15207. break;
  15208. }
  15209. };
  15210. return PlanePanel;
  15211. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15212. /***/ }),
  15213. /***/ "./3D/controls/scatterPanel.ts":
  15214. /*!*************************************!*\
  15215. !*** ./3D/controls/scatterPanel.ts ***!
  15216. \*************************************/
  15217. /*! exports provided: ScatterPanel */
  15218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15219. "use strict";
  15220. __webpack_require__.r(__webpack_exports__);
  15221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15222. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15223. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15224. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15225. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15226. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15227. /**
  15228. * Class used to create a container panel where items get randomized planar mapping
  15229. */
  15230. var ScatterPanel = /** @class */ (function (_super) {
  15231. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15232. function ScatterPanel() {
  15233. var _this = _super !== null && _super.apply(this, arguments) || this;
  15234. _this._iteration = 100.0;
  15235. return _this;
  15236. }
  15237. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15238. /**
  15239. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15240. */
  15241. get: function () {
  15242. return this._iteration;
  15243. },
  15244. set: function (value) {
  15245. var _this = this;
  15246. if (this._iteration === value) {
  15247. return;
  15248. }
  15249. this._iteration = value;
  15250. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15251. _this._arrangeChildren();
  15252. });
  15253. },
  15254. enumerable: false,
  15255. configurable: true
  15256. });
  15257. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15258. var mesh = control.mesh;
  15259. var newPos = this._scatterMapping(nodePosition);
  15260. if (!mesh) {
  15261. return;
  15262. }
  15263. switch (this.orientation) {
  15264. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15265. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15266. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15267. break;
  15268. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15269. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15270. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15271. break;
  15272. }
  15273. control.position = newPos;
  15274. };
  15275. ScatterPanel.prototype._scatterMapping = function (source) {
  15276. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15277. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15278. return source;
  15279. };
  15280. ScatterPanel.prototype._finalProcessing = function () {
  15281. var meshes = [];
  15282. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15283. var child = _a[_i];
  15284. if (!child.mesh) {
  15285. continue;
  15286. }
  15287. meshes.push(child.mesh);
  15288. }
  15289. for (var count = 0; count < this._iteration; count++) {
  15290. meshes.sort(function (a, b) {
  15291. var distance1 = a.position.lengthSquared();
  15292. var distance2 = b.position.lengthSquared();
  15293. if (distance1 < distance2) {
  15294. return 1;
  15295. }
  15296. else if (distance1 > distance2) {
  15297. return -1;
  15298. }
  15299. return 0;
  15300. });
  15301. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15302. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15303. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15304. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15305. for (var i = 0; i < meshes.length - 1; i++) {
  15306. for (var j = i + 1; j < meshes.length; j++) {
  15307. if (i != j) {
  15308. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15309. // Ignore Z axis
  15310. difference2D.x = difference.x;
  15311. difference2D.y = difference.y;
  15312. var combinedRadius = cellSize;
  15313. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15314. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15315. distance -= minSeparation;
  15316. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15317. difference2D.normalize();
  15318. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15319. meshes[j].position.addInPlace(difference);
  15320. meshes[i].position.subtractInPlace(difference);
  15321. }
  15322. }
  15323. }
  15324. }
  15325. }
  15326. };
  15327. return ScatterPanel;
  15328. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15329. /***/ }),
  15330. /***/ "./3D/controls/spherePanel.ts":
  15331. /*!************************************!*\
  15332. !*** ./3D/controls/spherePanel.ts ***!
  15333. \************************************/
  15334. /*! exports provided: SpherePanel */
  15335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15336. "use strict";
  15337. __webpack_require__.r(__webpack_exports__);
  15338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15339. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15340. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15341. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15342. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15343. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15344. /**
  15345. * Class used to create a container panel deployed on the surface of a sphere
  15346. */
  15347. var SpherePanel = /** @class */ (function (_super) {
  15348. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15349. function SpherePanel() {
  15350. var _this = _super !== null && _super.apply(this, arguments) || this;
  15351. _this._radius = 5.0;
  15352. return _this;
  15353. }
  15354. Object.defineProperty(SpherePanel.prototype, "radius", {
  15355. /**
  15356. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15357. */
  15358. get: function () {
  15359. return this._radius;
  15360. },
  15361. set: function (value) {
  15362. var _this = this;
  15363. if (this._radius === value) {
  15364. return;
  15365. }
  15366. this._radius = value;
  15367. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15368. _this._arrangeChildren();
  15369. });
  15370. },
  15371. enumerable: false,
  15372. configurable: true
  15373. });
  15374. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15375. var mesh = control.mesh;
  15376. if (!mesh) {
  15377. return;
  15378. }
  15379. var newPos = this._sphericalMapping(nodePosition);
  15380. control.position = newPos;
  15381. switch (this.orientation) {
  15382. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15383. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15384. break;
  15385. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15386. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15387. break;
  15388. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15389. break;
  15390. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15391. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15392. break;
  15393. }
  15394. };
  15395. SpherePanel.prototype._sphericalMapping = function (source) {
  15396. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15397. var xAngle = (source.y / this._radius);
  15398. var yAngle = -(source.x / this._radius);
  15399. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15400. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15401. };
  15402. return SpherePanel;
  15403. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15404. /***/ }),
  15405. /***/ "./3D/controls/stackPanel3D.ts":
  15406. /*!*************************************!*\
  15407. !*** ./3D/controls/stackPanel3D.ts ***!
  15408. \*************************************/
  15409. /*! exports provided: StackPanel3D */
  15410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15411. "use strict";
  15412. __webpack_require__.r(__webpack_exports__);
  15413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15414. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15415. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15416. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15417. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15418. /**
  15419. * Class used to create a stack panel in 3D on XY plane
  15420. */
  15421. var StackPanel3D = /** @class */ (function (_super) {
  15422. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15423. /**
  15424. * Creates new StackPanel
  15425. * @param isVertical
  15426. */
  15427. function StackPanel3D(isVertical) {
  15428. if (isVertical === void 0) { isVertical = false; }
  15429. var _this = _super.call(this) || this;
  15430. _this._isVertical = false;
  15431. /**
  15432. * Gets or sets the distance between elements
  15433. */
  15434. _this.margin = 0.1;
  15435. _this._isVertical = isVertical;
  15436. return _this;
  15437. }
  15438. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15439. /**
  15440. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15441. */
  15442. get: function () {
  15443. return this._isVertical;
  15444. },
  15445. set: function (value) {
  15446. var _this = this;
  15447. if (this._isVertical === value) {
  15448. return;
  15449. }
  15450. this._isVertical = value;
  15451. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15452. _this._arrangeChildren();
  15453. });
  15454. },
  15455. enumerable: false,
  15456. configurable: true
  15457. });
  15458. StackPanel3D.prototype._arrangeChildren = function () {
  15459. var width = 0;
  15460. var height = 0;
  15461. var controlCount = 0;
  15462. var extendSizes = [];
  15463. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15464. // Measure
  15465. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15466. var child = _a[_i];
  15467. if (!child.mesh) {
  15468. continue;
  15469. }
  15470. controlCount++;
  15471. child.mesh.computeWorldMatrix(true);
  15472. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15473. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15474. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15475. extendSizes.push(extendSize);
  15476. if (this._isVertical) {
  15477. height += extendSize.y;
  15478. }
  15479. else {
  15480. width += extendSize.x;
  15481. }
  15482. }
  15483. if (this._isVertical) {
  15484. height += (controlCount - 1) * this.margin / 2;
  15485. }
  15486. else {
  15487. width += (controlCount - 1) * this.margin / 2;
  15488. }
  15489. // Arrange
  15490. var offset;
  15491. if (this._isVertical) {
  15492. offset = -height;
  15493. }
  15494. else {
  15495. offset = -width;
  15496. }
  15497. var index = 0;
  15498. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15499. var child = _c[_b];
  15500. if (!child.mesh) {
  15501. continue;
  15502. }
  15503. controlCount--;
  15504. var extendSize = extendSizes[index++];
  15505. if (this._isVertical) {
  15506. child.position.y = offset + extendSize.y;
  15507. child.position.x = 0;
  15508. offset += extendSize.y * 2;
  15509. }
  15510. else {
  15511. child.position.x = offset + extendSize.x;
  15512. child.position.y = 0;
  15513. offset += extendSize.x * 2;
  15514. }
  15515. offset += (controlCount > 0 ? this.margin : 0);
  15516. }
  15517. };
  15518. return StackPanel3D;
  15519. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15520. /***/ }),
  15521. /***/ "./3D/controls/volumeBasedPanel.ts":
  15522. /*!*****************************************!*\
  15523. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15524. \*****************************************/
  15525. /*! exports provided: VolumeBasedPanel */
  15526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15527. "use strict";
  15528. __webpack_require__.r(__webpack_exports__);
  15529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15530. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15531. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15532. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15533. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15534. /**
  15535. * Abstract class used to create a container panel deployed on the surface of a volume
  15536. */
  15537. var VolumeBasedPanel = /** @class */ (function (_super) {
  15538. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15539. /**
  15540. * Creates new VolumeBasedPanel
  15541. */
  15542. function VolumeBasedPanel() {
  15543. var _this = _super.call(this) || this;
  15544. _this._columns = 10;
  15545. _this._rows = 0;
  15546. _this._rowThenColum = true;
  15547. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15548. /**
  15549. * Gets or sets the distance between elements
  15550. */
  15551. _this.margin = 0;
  15552. return _this;
  15553. }
  15554. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15555. /**
  15556. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15557. * | Value | Type | Description |
  15558. * | ----- | ----------------------------------- | ----------- |
  15559. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15560. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15561. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15562. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15563. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15564. */
  15565. get: function () {
  15566. return this._orientation;
  15567. },
  15568. set: function (value) {
  15569. var _this = this;
  15570. if (this._orientation === value) {
  15571. return;
  15572. }
  15573. this._orientation = value;
  15574. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15575. _this._arrangeChildren();
  15576. });
  15577. },
  15578. enumerable: false,
  15579. configurable: true
  15580. });
  15581. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15582. /**
  15583. * Gets or sets the number of columns requested (10 by default).
  15584. * The panel will automatically compute the number of rows based on number of child controls.
  15585. */
  15586. get: function () {
  15587. return this._columns;
  15588. },
  15589. set: function (value) {
  15590. var _this = this;
  15591. if (this._columns === value) {
  15592. return;
  15593. }
  15594. this._columns = value;
  15595. this._rowThenColum = true;
  15596. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15597. _this._arrangeChildren();
  15598. });
  15599. },
  15600. enumerable: false,
  15601. configurable: true
  15602. });
  15603. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15604. /**
  15605. * Gets or sets a the number of rows requested.
  15606. * The panel will automatically compute the number of columns based on number of child controls.
  15607. */
  15608. get: function () {
  15609. return this._rows;
  15610. },
  15611. set: function (value) {
  15612. var _this = this;
  15613. if (this._rows === value) {
  15614. return;
  15615. }
  15616. this._rows = value;
  15617. this._rowThenColum = false;
  15618. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15619. _this._arrangeChildren();
  15620. });
  15621. },
  15622. enumerable: false,
  15623. configurable: true
  15624. });
  15625. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15626. this._cellWidth = 0;
  15627. this._cellHeight = 0;
  15628. var rows = 0;
  15629. var columns = 0;
  15630. var controlCount = 0;
  15631. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15632. // Measure
  15633. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15634. var child = _a[_i];
  15635. if (!child.mesh) {
  15636. continue;
  15637. }
  15638. controlCount++;
  15639. child.mesh.computeWorldMatrix(true);
  15640. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15641. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15642. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15643. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15644. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15645. diff.scaleInPlace(0.5);
  15646. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15647. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15648. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15649. }
  15650. this._cellWidth += this.margin * 2;
  15651. this._cellHeight += this.margin * 2;
  15652. // Arrange
  15653. if (this._rowThenColum) {
  15654. columns = this._columns;
  15655. rows = Math.ceil(controlCount / this._columns);
  15656. }
  15657. else {
  15658. rows = this._rows;
  15659. columns = Math.ceil(controlCount / this._rows);
  15660. }
  15661. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15662. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15663. var nodeGrid = [];
  15664. var cellCounter = 0;
  15665. if (this._rowThenColum) {
  15666. for (var r = 0; r < rows; r++) {
  15667. for (var c = 0; c < columns; c++) {
  15668. 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));
  15669. cellCounter++;
  15670. if (cellCounter > controlCount) {
  15671. break;
  15672. }
  15673. }
  15674. }
  15675. }
  15676. else {
  15677. for (var c = 0; c < columns; c++) {
  15678. for (var r = 0; r < rows; r++) {
  15679. 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));
  15680. cellCounter++;
  15681. if (cellCounter > controlCount) {
  15682. break;
  15683. }
  15684. }
  15685. }
  15686. }
  15687. cellCounter = 0;
  15688. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15689. var child = _c[_b];
  15690. if (!child.mesh) {
  15691. continue;
  15692. }
  15693. this._mapGridNode(child, nodeGrid[cellCounter]);
  15694. cellCounter++;
  15695. }
  15696. this._finalProcessing();
  15697. };
  15698. /** Child classes can implement this function to provide additional processing */
  15699. VolumeBasedPanel.prototype._finalProcessing = function () {
  15700. };
  15701. return VolumeBasedPanel;
  15702. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15703. /***/ }),
  15704. /***/ "./3D/gui3DManager.ts":
  15705. /*!****************************!*\
  15706. !*** ./3D/gui3DManager.ts ***!
  15707. \****************************/
  15708. /*! exports provided: GUI3DManager */
  15709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15710. "use strict";
  15711. __webpack_require__.r(__webpack_exports__);
  15712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15713. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  15714. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15715. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15716. /**
  15717. * Class used to manage 3D user interface
  15718. * @see https://doc.babylonjs.com/how_to/gui3d
  15719. */
  15720. var GUI3DManager = /** @class */ (function () {
  15721. /**
  15722. * Creates a new GUI3DManager
  15723. * @param scene
  15724. */
  15725. function GUI3DManager(scene) {
  15726. var _this = this;
  15727. /** @hidden */
  15728. this._lastControlOver = {};
  15729. /** @hidden */
  15730. this._lastControlDown = {};
  15731. /**
  15732. * Observable raised when the point picked by the pointer events changed
  15733. */
  15734. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15735. // Shared resources
  15736. /** @hidden */
  15737. this._sharedMaterials = {};
  15738. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15739. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15740. _this._sceneDisposeObserver = null;
  15741. _this._utilityLayer = null;
  15742. _this.dispose();
  15743. });
  15744. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15745. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15746. this._utilityLayer.pickUtilitySceneFirst = false;
  15747. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15748. return mesh && mesh.metadata && mesh.metadata._node;
  15749. };
  15750. // Root
  15751. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15752. this._rootContainer._host = this;
  15753. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15754. // Events
  15755. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15756. _this._handlePointerOut(pointerId, true);
  15757. });
  15758. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15759. _this._doPicking(pi);
  15760. });
  15761. // Scene
  15762. this._utilityLayer.utilityLayerScene.autoClear = false;
  15763. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15764. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15765. }
  15766. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15767. /** Gets the hosting scene */
  15768. get: function () {
  15769. return this._scene;
  15770. },
  15771. enumerable: false,
  15772. configurable: true
  15773. });
  15774. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15775. /** Gets associated utility layer */
  15776. get: function () {
  15777. return this._utilityLayer;
  15778. },
  15779. enumerable: false,
  15780. configurable: true
  15781. });
  15782. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15783. var previousControlOver = this._lastControlOver[pointerId];
  15784. if (previousControlOver) {
  15785. previousControlOver._onPointerOut(previousControlOver);
  15786. delete this._lastControlOver[pointerId];
  15787. }
  15788. if (isPointerUp) {
  15789. if (this._lastControlDown[pointerId]) {
  15790. this._lastControlDown[pointerId].forcePointerUp();
  15791. delete this._lastControlDown[pointerId];
  15792. }
  15793. }
  15794. this.onPickedPointChangedObservable.notifyObservers(null);
  15795. };
  15796. GUI3DManager.prototype._doPicking = function (pi) {
  15797. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15798. return false;
  15799. }
  15800. var pointerEvent = (pi.event);
  15801. var pointerId = pointerEvent.pointerId || 0;
  15802. var buttonIndex = pointerEvent.button;
  15803. var pickingInfo = pi.pickInfo;
  15804. if (!pickingInfo || !pickingInfo.hit) {
  15805. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15806. return false;
  15807. }
  15808. var control = (pickingInfo.pickedMesh.metadata);
  15809. if (pickingInfo.pickedPoint) {
  15810. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15811. }
  15812. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15813. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15814. if (this._lastControlOver[pointerId]) {
  15815. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15816. }
  15817. delete this._lastControlOver[pointerId];
  15818. }
  15819. }
  15820. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15821. if (this._lastControlDown[pointerEvent.pointerId]) {
  15822. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15823. delete this._lastControlDown[pointerEvent.pointerId];
  15824. }
  15825. if (pointerEvent.pointerType === "touch") {
  15826. this._handlePointerOut(pointerId, false);
  15827. }
  15828. }
  15829. return true;
  15830. };
  15831. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15832. /**
  15833. * Gets the root container
  15834. */
  15835. get: function () {
  15836. return this._rootContainer;
  15837. },
  15838. enumerable: false,
  15839. configurable: true
  15840. });
  15841. /**
  15842. * Gets a boolean indicating if the given control is in the root child list
  15843. * @param control defines the control to check
  15844. * @returns true if the control is in the root child list
  15845. */
  15846. GUI3DManager.prototype.containsControl = function (control) {
  15847. return this._rootContainer.containsControl(control);
  15848. };
  15849. /**
  15850. * Adds a control to the root child list
  15851. * @param control defines the control to add
  15852. * @returns the current manager
  15853. */
  15854. GUI3DManager.prototype.addControl = function (control) {
  15855. this._rootContainer.addControl(control);
  15856. return this;
  15857. };
  15858. /**
  15859. * Removes a control from the root child list
  15860. * @param control defines the control to remove
  15861. * @returns the current container
  15862. */
  15863. GUI3DManager.prototype.removeControl = function (control) {
  15864. this._rootContainer.removeControl(control);
  15865. return this;
  15866. };
  15867. /**
  15868. * Releases all associated resources
  15869. */
  15870. GUI3DManager.prototype.dispose = function () {
  15871. this._rootContainer.dispose();
  15872. for (var materialName in this._sharedMaterials) {
  15873. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15874. continue;
  15875. }
  15876. this._sharedMaterials[materialName].dispose();
  15877. }
  15878. this._sharedMaterials = {};
  15879. if (this._pointerOutObserver && this._utilityLayer) {
  15880. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15881. this._pointerOutObserver = null;
  15882. }
  15883. this.onPickedPointChangedObservable.clear();
  15884. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15885. if (utilityLayerScene) {
  15886. if (this._pointerObserver) {
  15887. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15888. this._pointerObserver = null;
  15889. }
  15890. }
  15891. if (this._scene) {
  15892. if (this._sceneDisposeObserver) {
  15893. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15894. this._sceneDisposeObserver = null;
  15895. }
  15896. }
  15897. if (this._utilityLayer) {
  15898. this._utilityLayer.dispose();
  15899. }
  15900. };
  15901. return GUI3DManager;
  15902. }());
  15903. /***/ }),
  15904. /***/ "./3D/index.ts":
  15905. /*!*********************!*\
  15906. !*** ./3D/index.ts ***!
  15907. \*********************/
  15908. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  15909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15910. "use strict";
  15911. __webpack_require__.r(__webpack_exports__);
  15912. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15925. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15928. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15930. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15932. /***/ }),
  15933. /***/ "./3D/materials/fluentMaterial.ts":
  15934. /*!****************************************!*\
  15935. !*** ./3D/materials/fluentMaterial.ts ***!
  15936. \****************************************/
  15937. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15939. "use strict";
  15940. __webpack_require__.r(__webpack_exports__);
  15941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15943. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15944. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math.vector");
  15945. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15946. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15947. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15948. /** @hidden */
  15949. var FluentMaterialDefines = /** @class */ (function (_super) {
  15950. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15951. function FluentMaterialDefines() {
  15952. var _this = _super.call(this) || this;
  15953. _this.INNERGLOW = false;
  15954. _this.BORDER = false;
  15955. _this.HOVERLIGHT = false;
  15956. _this.TEXTURE = false;
  15957. _this.rebuild();
  15958. return _this;
  15959. }
  15960. return FluentMaterialDefines;
  15961. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15962. /**
  15963. * Class used to render controls with fluent desgin
  15964. */
  15965. var FluentMaterial = /** @class */ (function (_super) {
  15966. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15967. /**
  15968. * Creates a new Fluent material
  15969. * @param name defines the name of the material
  15970. * @param scene defines the hosting scene
  15971. */
  15972. function FluentMaterial(name, scene) {
  15973. var _this = _super.call(this, name, scene) || this;
  15974. /**
  15975. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15976. */
  15977. _this.innerGlowColorIntensity = 0.5;
  15978. /**
  15979. * Gets or sets the inner glow color (white by default)
  15980. */
  15981. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15982. /**
  15983. * Gets or sets alpha value (default is 1.0)
  15984. */
  15985. _this.alpha = 1.0;
  15986. /**
  15987. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15988. */
  15989. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15990. /**
  15991. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15992. */
  15993. _this.renderBorders = false;
  15994. /**
  15995. * Gets or sets border width (default is 0.5)
  15996. */
  15997. _this.borderWidth = 0.5;
  15998. /**
  15999. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  16000. */
  16001. _this.edgeSmoothingValue = 0.02;
  16002. /**
  16003. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  16004. */
  16005. _this.borderMinValue = 0.1;
  16006. /**
  16007. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  16008. */
  16009. _this.renderHoverLight = false;
  16010. /**
  16011. * Gets or sets the radius used to render the hover light (default is 1.0)
  16012. */
  16013. _this.hoverRadius = 1.0;
  16014. /**
  16015. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  16016. */
  16017. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  16018. /**
  16019. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  16020. */
  16021. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16022. return _this;
  16023. }
  16024. FluentMaterial.prototype.needAlphaBlending = function () {
  16025. return this.alpha !== 1.0;
  16026. };
  16027. FluentMaterial.prototype.needAlphaTesting = function () {
  16028. return false;
  16029. };
  16030. FluentMaterial.prototype.getAlphaTestTexture = function () {
  16031. return null;
  16032. };
  16033. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  16034. if (this.isFrozen) {
  16035. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  16036. return true;
  16037. }
  16038. }
  16039. if (!subMesh._materialDefines) {
  16040. subMesh._materialDefines = new FluentMaterialDefines();
  16041. }
  16042. var scene = this.getScene();
  16043. var defines = subMesh._materialDefines;
  16044. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  16045. if (defines._renderId === scene.getRenderId()) {
  16046. return true;
  16047. }
  16048. }
  16049. if (defines._areTexturesDirty) {
  16050. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  16051. defines.BORDER = this.renderBorders;
  16052. defines.HOVERLIGHT = this.renderHoverLight;
  16053. if (this._albedoTexture) {
  16054. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  16055. return false;
  16056. }
  16057. else {
  16058. defines.TEXTURE = true;
  16059. }
  16060. }
  16061. else {
  16062. defines.TEXTURE = false;
  16063. }
  16064. }
  16065. var engine = scene.getEngine();
  16066. // Get correct effect
  16067. if (defines.isDirty) {
  16068. defines.markAsProcessed();
  16069. scene.resetCachedMaterial();
  16070. //Attributes
  16071. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16072. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16073. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16074. var shaderName = "fluent";
  16075. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16076. "hoverColor", "hoverPosition", "hoverRadius"
  16077. ];
  16078. var samplers = ["albedoSampler"];
  16079. var uniformBuffers = new Array();
  16080. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16081. uniformsNames: uniforms,
  16082. uniformBuffersNames: uniformBuffers,
  16083. samplers: samplers,
  16084. defines: defines,
  16085. maxSimultaneousLights: 4
  16086. });
  16087. var join = defines.toString();
  16088. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16089. attributes: attribs,
  16090. uniformsNames: uniforms,
  16091. uniformBuffersNames: uniformBuffers,
  16092. samplers: samplers,
  16093. defines: join,
  16094. fallbacks: null,
  16095. onCompiled: this.onCompiled,
  16096. onError: this.onError,
  16097. indexParameters: { maxSimultaneousLights: 4 }
  16098. }, engine));
  16099. }
  16100. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16101. return false;
  16102. }
  16103. defines._renderId = scene.getRenderId();
  16104. subMesh.effect._wasPreviouslyReady = true;
  16105. return true;
  16106. };
  16107. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16108. var scene = this.getScene();
  16109. var defines = subMesh._materialDefines;
  16110. if (!defines) {
  16111. return;
  16112. }
  16113. var effect = subMesh.effect;
  16114. if (!effect) {
  16115. return;
  16116. }
  16117. this._activeEffect = effect;
  16118. // Matrices
  16119. this.bindOnlyWorldMatrix(world);
  16120. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16121. if (this._mustRebind(scene, effect)) {
  16122. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16123. if (defines.INNERGLOW) {
  16124. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16125. }
  16126. if (defines.BORDER) {
  16127. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16128. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16129. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16130. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16131. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16132. }
  16133. if (defines.HOVERLIGHT) {
  16134. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16135. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16136. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16137. }
  16138. if (defines.TEXTURE) {
  16139. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16140. }
  16141. }
  16142. this._afterBind(mesh, this._activeEffect);
  16143. };
  16144. FluentMaterial.prototype.getActiveTextures = function () {
  16145. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16146. return activeTextures;
  16147. };
  16148. FluentMaterial.prototype.hasTexture = function (texture) {
  16149. if (_super.prototype.hasTexture.call(this, texture)) {
  16150. return true;
  16151. }
  16152. return false;
  16153. };
  16154. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16155. _super.prototype.dispose.call(this, forceDisposeEffect);
  16156. };
  16157. FluentMaterial.prototype.clone = function (name) {
  16158. var _this = this;
  16159. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16160. };
  16161. FluentMaterial.prototype.serialize = function () {
  16162. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16163. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16164. return serializationObject;
  16165. };
  16166. FluentMaterial.prototype.getClassName = function () {
  16167. return "FluentMaterial";
  16168. };
  16169. // Statics
  16170. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16171. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16172. };
  16173. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16174. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16175. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16176. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16177. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16178. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16179. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16180. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16181. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16182. ], FluentMaterial.prototype, "alpha", void 0);
  16183. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16184. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16185. ], FluentMaterial.prototype, "albedoColor", void 0);
  16186. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16187. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16188. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16189. ], FluentMaterial.prototype, "renderBorders", void 0);
  16190. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16191. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16192. ], FluentMaterial.prototype, "borderWidth", void 0);
  16193. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16194. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16195. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16196. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16197. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16198. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16199. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16200. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16201. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16202. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16203. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16204. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16205. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16206. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16207. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16208. ], FluentMaterial.prototype, "hoverColor", void 0);
  16209. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16210. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16211. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16212. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16213. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16214. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16215. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16216. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16217. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16218. return FluentMaterial;
  16219. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16220. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16221. /***/ }),
  16222. /***/ "./3D/materials/index.ts":
  16223. /*!*******************************!*\
  16224. !*** ./3D/materials/index.ts ***!
  16225. \*******************************/
  16226. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16228. "use strict";
  16229. __webpack_require__.r(__webpack_exports__);
  16230. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16233. /***/ }),
  16234. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16235. /*!*************************************************!*\
  16236. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16237. \*************************************************/
  16238. /*! exports provided: fluentPixelShader */
  16239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16240. "use strict";
  16241. __webpack_require__.r(__webpack_exports__);
  16242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16243. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16244. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16245. var name = 'fluentPixelShader';
  16246. 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}";
  16247. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16248. /** @hidden */
  16249. var fluentPixelShader = { name: name, shader: shader };
  16250. /***/ }),
  16251. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16252. /*!***********************************************!*\
  16253. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16254. \***********************************************/
  16255. /*! exports provided: fluentVertexShader */
  16256. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16257. "use strict";
  16258. __webpack_require__.r(__webpack_exports__);
  16259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16260. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16261. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16262. var name = 'fluentVertexShader';
  16263. 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";
  16264. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16265. /** @hidden */
  16266. var fluentVertexShader = { name: name, shader: shader };
  16267. /***/ }),
  16268. /***/ "./3D/vector3WithInfo.ts":
  16269. /*!*******************************!*\
  16270. !*** ./3D/vector3WithInfo.ts ***!
  16271. \*******************************/
  16272. /*! exports provided: Vector3WithInfo */
  16273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16274. "use strict";
  16275. __webpack_require__.r(__webpack_exports__);
  16276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16278. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  16279. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16280. /**
  16281. * Class used to transport Vector3 information for pointer events
  16282. */
  16283. var Vector3WithInfo = /** @class */ (function (_super) {
  16284. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16285. /**
  16286. * Creates a new Vector3WithInfo
  16287. * @param source defines the vector3 data to transport
  16288. * @param buttonIndex defines the current mouse button index
  16289. */
  16290. function Vector3WithInfo(source,
  16291. /** defines the current mouse button index */
  16292. buttonIndex) {
  16293. if (buttonIndex === void 0) { buttonIndex = 0; }
  16294. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16295. _this.buttonIndex = buttonIndex;
  16296. return _this;
  16297. }
  16298. return Vector3WithInfo;
  16299. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16300. /***/ }),
  16301. /***/ "./index.ts":
  16302. /*!******************!*\
  16303. !*** ./index.ts ***!
  16304. \******************/
  16305. /*! 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 */
  16306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16307. "use strict";
  16308. __webpack_require__.r(__webpack_exports__);
  16309. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16351. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16368. /***/ }),
  16369. /***/ "./legacy/legacy.ts":
  16370. /*!**************************!*\
  16371. !*** ./legacy/legacy.ts ***!
  16372. \**************************/
  16373. /*! 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 */
  16374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16375. "use strict";
  16376. __webpack_require__.r(__webpack_exports__);
  16377. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16435. /**
  16436. * Legacy support, defining window.BABYLON.GUI (global variable).
  16437. *
  16438. * This is the entry point for the UMD module.
  16439. * The entry point for a future ESM package should be index.ts
  16440. */
  16441. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16442. if (typeof globalObject !== "undefined") {
  16443. globalObject.BABYLON = globalObject.BABYLON || {};
  16444. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16445. }
  16446. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16447. /***/ }),
  16448. /***/ "babylonjs/Maths/math.vector":
  16449. /*!****************************************************************************************************!*\
  16450. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16451. \****************************************************************************************************/
  16452. /*! no static exports found */
  16453. /***/ (function(module, exports) {
  16454. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__;
  16455. /***/ })
  16456. /******/ });
  16457. });
  16458. //# sourceMappingURL=babylon.gui.js.map