babylon.gui.js 705 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185
  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__) {
  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. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @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
  738. * @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
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootCanvas = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootCanvas) {
  1064. this._rootCanvas.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  1360. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1361. /**
  1362. * Class used to create 2D buttons
  1363. */
  1364. var Button = /** @class */ (function (_super) {
  1365. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1366. /**
  1367. * Creates a new Button
  1368. * @param name defines the name of the button
  1369. */
  1370. function Button(name) {
  1371. var _this = _super.call(this, name) || this;
  1372. _this.name = name;
  1373. /**
  1374. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1375. */
  1376. _this.delegatePickingToChildren = false;
  1377. _this.thickness = 1;
  1378. _this.isPointerBlocker = true;
  1379. var alphaStore = null;
  1380. _this.pointerEnterAnimation = function () {
  1381. alphaStore = _this.alpha;
  1382. _this.alpha -= 0.1;
  1383. };
  1384. _this.pointerOutAnimation = function () {
  1385. if (alphaStore !== null) {
  1386. _this.alpha = alphaStore;
  1387. }
  1388. };
  1389. _this.pointerDownAnimation = function () {
  1390. _this.scaleX -= 0.05;
  1391. _this.scaleY -= 0.05;
  1392. };
  1393. _this.pointerUpAnimation = function () {
  1394. _this.scaleX += 0.05;
  1395. _this.scaleY += 0.05;
  1396. };
  1397. return _this;
  1398. }
  1399. Object.defineProperty(Button.prototype, "image", {
  1400. /**
  1401. * Returns the image part of the button (if any)
  1402. */
  1403. get: function () {
  1404. return this._image;
  1405. },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Object.defineProperty(Button.prototype, "textBlock", {
  1410. /**
  1411. * Returns the image part of the button (if any)
  1412. */
  1413. get: function () {
  1414. return this._textBlock;
  1415. },
  1416. enumerable: true,
  1417. configurable: true
  1418. });
  1419. Button.prototype._getTypeName = function () {
  1420. return "Button";
  1421. };
  1422. // While being a container, the button behaves like a control.
  1423. /** @hidden */
  1424. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1425. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1426. return false;
  1427. }
  1428. if (!_super.prototype.contains.call(this, x, y)) {
  1429. return false;
  1430. }
  1431. if (this.delegatePickingToChildren) {
  1432. var contains = false;
  1433. for (var index = this._children.length - 1; index >= 0; index--) {
  1434. var child = this._children[index];
  1435. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1436. contains = true;
  1437. break;
  1438. }
  1439. }
  1440. if (!contains) {
  1441. return false;
  1442. }
  1443. }
  1444. this._processObservables(type, x, y, pointerId, buttonIndex);
  1445. return true;
  1446. };
  1447. /** @hidden */
  1448. Button.prototype._onPointerEnter = function (target) {
  1449. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1450. return false;
  1451. }
  1452. if (this.pointerEnterAnimation) {
  1453. this.pointerEnterAnimation();
  1454. }
  1455. return true;
  1456. };
  1457. /** @hidden */
  1458. Button.prototype._onPointerOut = function (target, force) {
  1459. if (force === void 0) { force = false; }
  1460. if (this.pointerOutAnimation) {
  1461. this.pointerOutAnimation();
  1462. }
  1463. _super.prototype._onPointerOut.call(this, target, force);
  1464. };
  1465. /** @hidden */
  1466. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1467. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1468. return false;
  1469. }
  1470. if (this.pointerDownAnimation) {
  1471. this.pointerDownAnimation();
  1472. }
  1473. return true;
  1474. };
  1475. /** @hidden */
  1476. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1477. if (this.pointerUpAnimation) {
  1478. this.pointerUpAnimation();
  1479. }
  1480. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1481. };
  1482. // Statics
  1483. /**
  1484. * Creates a new button made with an image and a text
  1485. * @param name defines the name of the button
  1486. * @param text defines the text of the button
  1487. * @param imageUrl defines the url of the image
  1488. * @returns a new Button
  1489. */
  1490. Button.CreateImageButton = function (name, text, imageUrl) {
  1491. var result = new Button(name);
  1492. // Adding text
  1493. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1494. textBlock.textWrapping = true;
  1495. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1496. textBlock.paddingLeft = "20%";
  1497. result.addControl(textBlock);
  1498. // Adding image
  1499. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1500. iconImage.width = "20%";
  1501. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1502. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1503. result.addControl(iconImage);
  1504. // Store
  1505. result._image = iconImage;
  1506. result._textBlock = textBlock;
  1507. return result;
  1508. };
  1509. /**
  1510. * Creates a new button made with an image
  1511. * @param name defines the name of the button
  1512. * @param imageUrl defines the url of the image
  1513. * @returns a new Button
  1514. */
  1515. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1516. var result = new Button(name);
  1517. // Adding image
  1518. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1519. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1520. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1521. result.addControl(iconImage);
  1522. // Store
  1523. result._image = iconImage;
  1524. return result;
  1525. };
  1526. /**
  1527. * Creates a new button made with a text
  1528. * @param name defines the name of the button
  1529. * @param text defines the text of the button
  1530. * @returns a new Button
  1531. */
  1532. Button.CreateSimpleButton = function (name, text) {
  1533. var result = new Button(name);
  1534. // Adding text
  1535. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1536. textBlock.textWrapping = true;
  1537. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1538. result.addControl(textBlock);
  1539. // Store
  1540. result._textBlock = textBlock;
  1541. return result;
  1542. };
  1543. /**
  1544. * Creates a new button made with an image and a centered text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1551. var result = new Button(name);
  1552. // Adding image
  1553. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1554. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1555. result.addControl(iconImage);
  1556. // Adding text
  1557. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1558. textBlock.textWrapping = true;
  1559. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1560. result.addControl(textBlock);
  1561. // Store
  1562. result._image = iconImage;
  1563. result._textBlock = textBlock;
  1564. return result;
  1565. };
  1566. return Button;
  1567. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1568. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1569. /***/ }),
  1570. /***/ "./2D/controls/checkbox.ts":
  1571. /*!*********************************!*\
  1572. !*** ./2D/controls/checkbox.ts ***!
  1573. \*********************************/
  1574. /*! exports provided: Checkbox */
  1575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1576. "use strict";
  1577. __webpack_require__.r(__webpack_exports__);
  1578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1580. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1582. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1583. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1584. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1585. /**
  1586. * Class used to represent a 2D checkbox
  1587. */
  1588. var Checkbox = /** @class */ (function (_super) {
  1589. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1590. /**
  1591. * Creates a new CheckBox
  1592. * @param name defines the control name
  1593. */
  1594. function Checkbox(name) {
  1595. var _this = _super.call(this, name) || this;
  1596. _this.name = name;
  1597. _this._isChecked = false;
  1598. _this._background = "black";
  1599. _this._checkSizeRatio = 0.8;
  1600. _this._thickness = 1;
  1601. /**
  1602. * Observable raised when isChecked property changes
  1603. */
  1604. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1605. _this.isPointerBlocker = true;
  1606. return _this;
  1607. }
  1608. Object.defineProperty(Checkbox.prototype, "thickness", {
  1609. /** Gets or sets border thickness */
  1610. get: function () {
  1611. return this._thickness;
  1612. },
  1613. set: function (value) {
  1614. if (this._thickness === value) {
  1615. return;
  1616. }
  1617. this._thickness = value;
  1618. this._markAsDirty();
  1619. },
  1620. enumerable: true,
  1621. configurable: true
  1622. });
  1623. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1624. /** Gets or sets a value indicating the ratio between overall size and check size */
  1625. get: function () {
  1626. return this._checkSizeRatio;
  1627. },
  1628. set: function (value) {
  1629. value = Math.max(Math.min(1, value), 0);
  1630. if (this._checkSizeRatio === value) {
  1631. return;
  1632. }
  1633. this._checkSizeRatio = value;
  1634. this._markAsDirty();
  1635. },
  1636. enumerable: true,
  1637. configurable: true
  1638. });
  1639. Object.defineProperty(Checkbox.prototype, "background", {
  1640. /** Gets or sets background color */
  1641. get: function () {
  1642. return this._background;
  1643. },
  1644. set: function (value) {
  1645. if (this._background === value) {
  1646. return;
  1647. }
  1648. this._background = value;
  1649. this._markAsDirty();
  1650. },
  1651. enumerable: true,
  1652. configurable: true
  1653. });
  1654. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1655. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1656. get: function () {
  1657. return this._isChecked;
  1658. },
  1659. set: function (value) {
  1660. if (this._isChecked === value) {
  1661. return;
  1662. }
  1663. this._isChecked = value;
  1664. this._markAsDirty();
  1665. this.onIsCheckedChangedObservable.notifyObservers(value);
  1666. },
  1667. enumerable: true,
  1668. configurable: true
  1669. });
  1670. Checkbox.prototype._getTypeName = function () {
  1671. return "Checkbox";
  1672. };
  1673. /** @hidden */
  1674. Checkbox.prototype._draw = function (context) {
  1675. context.save();
  1676. this._applyStates(context);
  1677. var actualWidth = this._currentMeasure.width - this._thickness;
  1678. var actualHeight = this._currentMeasure.height - this._thickness;
  1679. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1680. context.shadowColor = this.shadowColor;
  1681. context.shadowBlur = this.shadowBlur;
  1682. context.shadowOffsetX = this.shadowOffsetX;
  1683. context.shadowOffsetY = this.shadowOffsetY;
  1684. }
  1685. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1686. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1687. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1688. context.shadowBlur = 0;
  1689. context.shadowOffsetX = 0;
  1690. context.shadowOffsetY = 0;
  1691. }
  1692. if (this._isChecked) {
  1693. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1694. var offsetWidth = actualWidth * this._checkSizeRatio;
  1695. var offseHeight = actualHeight * this._checkSizeRatio;
  1696. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1697. }
  1698. context.strokeStyle = this.color;
  1699. context.lineWidth = this._thickness;
  1700. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1701. context.restore();
  1702. };
  1703. // Events
  1704. /** @hidden */
  1705. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1706. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1707. return false;
  1708. }
  1709. this.isChecked = !this.isChecked;
  1710. return true;
  1711. };
  1712. /**
  1713. * Utility function to easily create a checkbox with a header
  1714. * @param title defines the label to use for the header
  1715. * @param onValueChanged defines the callback to call when value changes
  1716. * @returns a StackPanel containing the checkbox and a textBlock
  1717. */
  1718. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1719. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1720. panel.isVertical = false;
  1721. panel.height = "30px";
  1722. var checkbox = new Checkbox();
  1723. checkbox.width = "20px";
  1724. checkbox.height = "20px";
  1725. checkbox.isChecked = true;
  1726. checkbox.color = "green";
  1727. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1728. panel.addControl(checkbox);
  1729. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1730. header.text = title;
  1731. header.width = "180px";
  1732. header.paddingLeft = "5px";
  1733. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1734. header.color = "white";
  1735. panel.addControl(header);
  1736. return panel;
  1737. };
  1738. return Checkbox;
  1739. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1740. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1741. /***/ }),
  1742. /***/ "./2D/controls/colorpicker.ts":
  1743. /*!************************************!*\
  1744. !*** ./2D/controls/colorpicker.ts ***!
  1745. \************************************/
  1746. /*! exports provided: ColorPicker */
  1747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1748. "use strict";
  1749. __webpack_require__.r(__webpack_exports__);
  1750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1752. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1753. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1754. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1755. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1756. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1757. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1758. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1759. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1760. /** Class used to create color pickers */
  1761. var ColorPicker = /** @class */ (function (_super) {
  1762. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1763. /**
  1764. * Creates a new ColorPicker
  1765. * @param name defines the control name
  1766. */
  1767. function ColorPicker(name) {
  1768. var _this = _super.call(this, name) || this;
  1769. _this.name = name;
  1770. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1771. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1772. _this._pointerStartedOnSquare = false;
  1773. _this._pointerStartedOnWheel = false;
  1774. _this._squareLeft = 0;
  1775. _this._squareTop = 0;
  1776. _this._squareSize = 0;
  1777. _this._h = 360;
  1778. _this._s = 1;
  1779. _this._v = 1;
  1780. _this._lastPointerDownID = -1;
  1781. /**
  1782. * Observable raised when the value changes
  1783. */
  1784. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1785. // Events
  1786. _this._pointerIsDown = false;
  1787. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1788. _this.size = "200px";
  1789. _this.isPointerBlocker = true;
  1790. return _this;
  1791. }
  1792. Object.defineProperty(ColorPicker.prototype, "value", {
  1793. /** Gets or sets the color of the color picker */
  1794. get: function () {
  1795. return this._value;
  1796. },
  1797. set: function (value) {
  1798. if (this._value.equals(value)) {
  1799. return;
  1800. }
  1801. this._value.copyFrom(value);
  1802. this._value.toHSVToRef(this._tmpColor);
  1803. this._h = this._tmpColor.r;
  1804. this._s = Math.max(this._tmpColor.g, 0.00001);
  1805. this._v = Math.max(this._tmpColor.b, 0.00001);
  1806. this._markAsDirty();
  1807. if (this._value.r <= ColorPicker._Epsilon) {
  1808. this._value.r = 0;
  1809. }
  1810. if (this._value.g <= ColorPicker._Epsilon) {
  1811. this._value.g = 0;
  1812. }
  1813. if (this._value.b <= ColorPicker._Epsilon) {
  1814. this._value.b = 0;
  1815. }
  1816. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1817. this._value.r = 1.0;
  1818. }
  1819. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1820. this._value.g = 1.0;
  1821. }
  1822. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1823. this._value.b = 1.0;
  1824. }
  1825. this.onValueChangedObservable.notifyObservers(this._value);
  1826. },
  1827. enumerable: true,
  1828. configurable: true
  1829. });
  1830. Object.defineProperty(ColorPicker.prototype, "width", {
  1831. /**
  1832. * Gets or sets control width
  1833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1834. */
  1835. get: function () {
  1836. return this._width.toString(this._host);
  1837. },
  1838. set: function (value) {
  1839. if (this._width.toString(this._host) === value) {
  1840. return;
  1841. }
  1842. if (this._width.fromString(value)) {
  1843. this._height.fromString(value);
  1844. this._markAsDirty();
  1845. }
  1846. },
  1847. enumerable: true,
  1848. configurable: true
  1849. });
  1850. Object.defineProperty(ColorPicker.prototype, "height", {
  1851. /**
  1852. * Gets or sets control height
  1853. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1854. */
  1855. get: function () {
  1856. return this._height.toString(this._host);
  1857. },
  1858. /** Gets or sets control height */
  1859. set: function (value) {
  1860. if (this._height.toString(this._host) === value) {
  1861. return;
  1862. }
  1863. if (this._height.fromString(value)) {
  1864. this._width.fromString(value);
  1865. this._markAsDirty();
  1866. }
  1867. },
  1868. enumerable: true,
  1869. configurable: true
  1870. });
  1871. Object.defineProperty(ColorPicker.prototype, "size", {
  1872. /** Gets or sets control size */
  1873. get: function () {
  1874. return this.width;
  1875. },
  1876. set: function (value) {
  1877. this.width = value;
  1878. },
  1879. enumerable: true,
  1880. configurable: true
  1881. });
  1882. ColorPicker.prototype._getTypeName = function () {
  1883. return "ColorPicker";
  1884. };
  1885. /** @hidden */
  1886. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1887. if (parentMeasure.width < parentMeasure.height) {
  1888. this._currentMeasure.height = parentMeasure.width;
  1889. }
  1890. else {
  1891. this._currentMeasure.width = parentMeasure.height;
  1892. }
  1893. };
  1894. ColorPicker.prototype._updateSquareProps = function () {
  1895. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1896. var wheelThickness = radius * .2;
  1897. var innerDiameter = (radius - wheelThickness) * 2;
  1898. var squareSize = innerDiameter / (Math.sqrt(2));
  1899. var offset = radius - squareSize * .5;
  1900. this._squareLeft = this._currentMeasure.left + offset;
  1901. this._squareTop = this._currentMeasure.top + offset;
  1902. this._squareSize = squareSize;
  1903. };
  1904. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1905. var lgh = context.createLinearGradient(left, top, width + left, top);
  1906. lgh.addColorStop(0, '#fff');
  1907. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1908. context.fillStyle = lgh;
  1909. context.fillRect(left, top, width, height);
  1910. var lgv = context.createLinearGradient(left, top, left, height + top);
  1911. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1912. lgv.addColorStop(1, '#000');
  1913. context.fillStyle = lgv;
  1914. context.fillRect(left, top, width, height);
  1915. };
  1916. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1917. context.beginPath();
  1918. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1919. context.lineWidth = 3;
  1920. context.strokeStyle = '#333333';
  1921. context.stroke();
  1922. context.beginPath();
  1923. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1924. context.lineWidth = 3;
  1925. context.strokeStyle = '#ffffff';
  1926. context.stroke();
  1927. };
  1928. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1929. var canvas = document.createElement("canvas");
  1930. canvas.width = radius * 2;
  1931. canvas.height = radius * 2;
  1932. var context = canvas.getContext("2d");
  1933. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1934. var data = image.data;
  1935. var color = this._tmpColor;
  1936. var maxDistSq = radius * radius;
  1937. var innerRadius = radius - thickness;
  1938. var minDistSq = innerRadius * innerRadius;
  1939. for (var x = -radius; x < radius; x++) {
  1940. for (var y = -radius; y < radius; y++) {
  1941. var distSq = x * x + y * y;
  1942. if (distSq > maxDistSq || distSq < minDistSq) {
  1943. continue;
  1944. }
  1945. var dist = Math.sqrt(distSq);
  1946. var ang = Math.atan2(y, x);
  1947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1948. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1949. data[index] = color.r * 255;
  1950. data[index + 1] = color.g * 255;
  1951. data[index + 2] = color.b * 255;
  1952. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1953. //apply less alpha to bigger color pickers
  1954. var alphaAmount = .2;
  1955. var maxAlpha = .2;
  1956. var minAlpha = .04;
  1957. var lowerRadius = 50;
  1958. var upperRadius = 150;
  1959. if (radius < lowerRadius) {
  1960. alphaAmount = maxAlpha;
  1961. }
  1962. else if (radius > upperRadius) {
  1963. alphaAmount = minAlpha;
  1964. }
  1965. else {
  1966. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1967. }
  1968. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1969. if (alphaRatio < alphaAmount) {
  1970. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1971. }
  1972. else if (alphaRatio > 1 - alphaAmount) {
  1973. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1974. }
  1975. else {
  1976. data[index + 3] = 255;
  1977. }
  1978. }
  1979. }
  1980. context.putImageData(image, 0, 0);
  1981. return canvas;
  1982. };
  1983. /** @hidden */
  1984. ColorPicker.prototype._draw = function (context) {
  1985. context.save();
  1986. this._applyStates(context);
  1987. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1988. var wheelThickness = radius * .2;
  1989. var left = this._currentMeasure.left;
  1990. var top = this._currentMeasure.top;
  1991. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1992. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1993. }
  1994. this._updateSquareProps();
  1995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1996. context.shadowColor = this.shadowColor;
  1997. context.shadowBlur = this.shadowBlur;
  1998. context.shadowOffsetX = this.shadowOffsetX;
  1999. context.shadowOffsetY = this.shadowOffsetY;
  2000. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2001. }
  2002. context.drawImage(this._colorWheelCanvas, left, top);
  2003. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2004. context.shadowBlur = 0;
  2005. context.shadowOffsetX = 0;
  2006. context.shadowOffsetY = 0;
  2007. }
  2008. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2009. var cx = this._squareLeft + this._squareSize * this._s;
  2010. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2011. this._drawCircle(cx, cy, radius * .04, context);
  2012. var dist = radius - wheelThickness * .5;
  2013. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2014. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2015. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2016. context.restore();
  2017. };
  2018. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2019. if (this._pointerStartedOnWheel) {
  2020. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2021. var centerX = radius + this._currentMeasure.left;
  2022. var centerY = radius + this._currentMeasure.top;
  2023. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2024. }
  2025. else if (this._pointerStartedOnSquare) {
  2026. this._updateSquareProps();
  2027. this._s = (x - this._squareLeft) / this._squareSize;
  2028. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2029. this._s = Math.min(this._s, 1);
  2030. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2031. this._v = Math.min(this._v, 1);
  2032. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2033. }
  2034. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2035. this.value = this._tmpColor;
  2036. };
  2037. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2038. this._updateSquareProps();
  2039. var left = this._squareLeft;
  2040. var top = this._squareTop;
  2041. var size = this._squareSize;
  2042. if (x >= left && x <= left + size &&
  2043. y >= top && y <= top + size) {
  2044. return true;
  2045. }
  2046. return false;
  2047. };
  2048. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2049. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2050. var centerX = radius + this._currentMeasure.left;
  2051. var centerY = radius + this._currentMeasure.top;
  2052. var wheelThickness = radius * .2;
  2053. var innerRadius = radius - wheelThickness;
  2054. var radiusSq = radius * radius;
  2055. var innerRadiusSq = innerRadius * innerRadius;
  2056. var dx = x - centerX;
  2057. var dy = y - centerY;
  2058. var distSq = dx * dx + dy * dy;
  2059. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2060. return true;
  2061. }
  2062. return false;
  2063. };
  2064. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2065. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2066. return false;
  2067. }
  2068. this._pointerIsDown = true;
  2069. this._pointerStartedOnSquare = false;
  2070. this._pointerStartedOnWheel = false;
  2071. // Invert transform
  2072. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2073. var x = this._transformedPosition.x;
  2074. var y = this._transformedPosition.y;
  2075. if (this._isPointOnSquare(x, y)) {
  2076. this._pointerStartedOnSquare = true;
  2077. }
  2078. else if (this._isPointOnWheel(x, y)) {
  2079. this._pointerStartedOnWheel = true;
  2080. }
  2081. this._updateValueFromPointer(x, y);
  2082. this._host._capturingControl[pointerId] = this;
  2083. this._lastPointerDownID = pointerId;
  2084. return true;
  2085. };
  2086. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2087. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2088. if (pointerId != this._lastPointerDownID) {
  2089. return;
  2090. }
  2091. // Invert transform
  2092. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2093. var x = this._transformedPosition.x;
  2094. var y = this._transformedPosition.y;
  2095. if (this._pointerIsDown) {
  2096. this._updateValueFromPointer(x, y);
  2097. }
  2098. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2099. };
  2100. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2101. this._pointerIsDown = false;
  2102. delete this._host._capturingControl[pointerId];
  2103. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2104. };
  2105. /**
  2106. * This function expands the color picker by creating a color picker dialog with manual
  2107. * color value input and the ability to save colors into an array to be used later in
  2108. * subsequent launches of the dialogue.
  2109. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2110. * @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.
  2111. * @returns picked color as a hex string and the saved colors array as hex strings.
  2112. */
  2113. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2114. return new Promise(function (resolve, reject) {
  2115. // Default options
  2116. options.pickerWidth = options.pickerWidth || "640px";
  2117. options.pickerHeight = options.pickerHeight || "400px";
  2118. options.headerHeight = options.headerHeight || "35px";
  2119. options.lastColor = options.lastColor || "#000000";
  2120. options.swatchLimit = options.swatchLimit || 20;
  2121. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2122. // Window size settings
  2123. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2124. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2125. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2126. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2127. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2128. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2129. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2130. // Button Colors
  2131. var buttonColor = "#c0c0c0";
  2132. var buttonBackgroundColor = "#535353";
  2133. var buttonBackgroundHoverColor = "#414141";
  2134. var buttonBackgroundClickColor = "515151";
  2135. var buttonDisabledColor = "#555555";
  2136. var buttonDisabledBackgroundColor = "#454545";
  2137. var currentSwatchesOutlineColor = "#404040";
  2138. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2139. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2140. var iconColorDark = "#aaaaaa";
  2141. var iconColorLight = "#ffffff";
  2142. var closeIconColor;
  2143. // Button settings
  2144. var buttonFontSize;
  2145. var butEdit;
  2146. var buttonWidth;
  2147. var buttonHeight;
  2148. // Input Text Colors
  2149. var inputFieldLabels = ["R", "G", "B"];
  2150. var inputTextBackgroundColor = "#454545";
  2151. var inputTextColor = "#f0f0f0";
  2152. // This is the current color as set by either the picker or by entering a value
  2153. var currentColor;
  2154. // This int is used for naming swatches and serves as the index for calling them from the list
  2155. var swatchNumber;
  2156. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2157. var swatchDrawer;
  2158. var editSwatchMode = false;
  2159. // Color InputText fields that will be updated upon value change
  2160. var picker;
  2161. var rValInt;
  2162. var gValInt;
  2163. var bValInt;
  2164. var rValDec;
  2165. var gValDec;
  2166. var bValDec;
  2167. var hexVal;
  2168. var newSwatch;
  2169. var lastVal;
  2170. var activeField;
  2171. /**
  2172. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2173. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2174. * are will receive no update. This is to prevent the input from the user being overwritten.
  2175. */
  2176. function updateValues(value, inputField) {
  2177. activeField = inputField;
  2178. var pickedColor = value.toHexString();
  2179. newSwatch.background = pickedColor;
  2180. if (rValInt.name != activeField) {
  2181. rValInt.text = Math.floor(value.r * 255).toString();
  2182. }
  2183. if (gValInt.name != activeField) {
  2184. gValInt.text = Math.floor(value.g * 255).toString();
  2185. }
  2186. if (bValInt.name != activeField) {
  2187. bValInt.text = Math.floor(value.b * 255).toString();
  2188. }
  2189. if (rValDec.name != activeField) {
  2190. rValDec.text = value.r.toString();
  2191. }
  2192. if (gValDec.name != activeField) {
  2193. gValDec.text = value.g.toString();
  2194. }
  2195. if (bValDec.name != activeField) {
  2196. bValDec.text = value.b.toString();
  2197. }
  2198. if (hexVal.name != activeField) {
  2199. var minusPound = pickedColor.split("#");
  2200. hexVal.text = minusPound[1];
  2201. }
  2202. if (picker.name != activeField) {
  2203. picker.value = value;
  2204. }
  2205. }
  2206. // 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.
  2207. function updateInt(field, channel) {
  2208. var newValue = field.text;
  2209. var checkVal = /[^0-9]/g.test(newValue);
  2210. if (checkVal) {
  2211. field.text = lastVal;
  2212. return;
  2213. }
  2214. else {
  2215. if (newValue != "") {
  2216. if (Math.floor(parseInt(newValue)) < 0) {
  2217. newValue = "0";
  2218. }
  2219. else if (Math.floor(parseInt(newValue)) > 255) {
  2220. newValue = "255";
  2221. }
  2222. else if (isNaN(parseInt(newValue))) {
  2223. newValue = "0";
  2224. }
  2225. }
  2226. if (activeField == field.name) {
  2227. lastVal = newValue;
  2228. }
  2229. }
  2230. if (newValue != "") {
  2231. newValue = parseInt(newValue).toString();
  2232. field.text = newValue;
  2233. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2234. if (activeField == field.name) {
  2235. if (channel == "r") {
  2236. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2237. }
  2238. else if (channel == "g") {
  2239. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2240. }
  2241. else {
  2242. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2243. }
  2244. }
  2245. }
  2246. }
  2247. // 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.
  2248. function updateFloat(field, channel) {
  2249. var newValue = field.text;
  2250. var checkVal = /[^0-9\.]/g.test(newValue);
  2251. if (checkVal) {
  2252. field.text = lastVal;
  2253. return;
  2254. }
  2255. else {
  2256. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2257. if (parseFloat(newValue) < 0.0) {
  2258. newValue = "0.0";
  2259. }
  2260. else if (parseFloat(newValue) > 1.0) {
  2261. newValue = "1.0";
  2262. }
  2263. else if (isNaN(parseFloat(newValue))) {
  2264. newValue = "0.0";
  2265. }
  2266. }
  2267. if (activeField == field.name) {
  2268. lastVal = newValue;
  2269. }
  2270. }
  2271. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2272. newValue = parseFloat(newValue).toString();
  2273. field.text = newValue;
  2274. }
  2275. else {
  2276. newValue = "0.0";
  2277. }
  2278. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2279. if (activeField == field.name) {
  2280. if (channel == "r") {
  2281. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2282. }
  2283. else if (channel == "g") {
  2284. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2285. }
  2286. else {
  2287. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2288. }
  2289. }
  2290. }
  2291. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2292. function deleteSwatch(index) {
  2293. if (options.savedColors) {
  2294. options.savedColors.splice(index, 1);
  2295. }
  2296. if (options.savedColors && options.savedColors.length == 0) {
  2297. setEditButtonVisibility(false);
  2298. editSwatchMode = false;
  2299. }
  2300. }
  2301. // Creates and styles an individual swatch when updateSwatches is called.
  2302. function createSwatch() {
  2303. if (options.savedColors && options.savedColors[swatchNumber]) {
  2304. if (editSwatchMode) {
  2305. var icon = "b";
  2306. }
  2307. else {
  2308. var icon = "";
  2309. }
  2310. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2311. swatch.fontFamily = "BabylonJSglyphs";
  2312. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2313. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2314. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2315. if (swatchLuminence > luminanceLimit) {
  2316. swatch.color = iconColorDark;
  2317. }
  2318. else {
  2319. swatch.color = iconColorLight;
  2320. }
  2321. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2322. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2323. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2324. swatch.background = options.savedColors[swatchNumber];
  2325. swatch.thickness = 2;
  2326. var metadata_1 = swatchNumber;
  2327. swatch.pointerDownAnimation = function () {
  2328. swatch.thickness = 4;
  2329. };
  2330. swatch.pointerUpAnimation = function () {
  2331. swatch.thickness = 3;
  2332. };
  2333. swatch.pointerEnterAnimation = function () {
  2334. swatch.thickness = 3;
  2335. };
  2336. swatch.pointerOutAnimation = function () {
  2337. swatch.thickness = 2;
  2338. };
  2339. swatch.onPointerClickObservable.add(function () {
  2340. if (!editSwatchMode) {
  2341. if (options.savedColors) {
  2342. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2343. }
  2344. }
  2345. else {
  2346. deleteSwatch(metadata_1);
  2347. updateSwatches("", butSave);
  2348. }
  2349. });
  2350. return swatch;
  2351. }
  2352. else {
  2353. return null;
  2354. }
  2355. }
  2356. // Mode switch to render button text and close symbols on swatch controls
  2357. function editSwatches(mode) {
  2358. if (mode !== undefined) {
  2359. editSwatchMode = mode;
  2360. }
  2361. if (editSwatchMode) {
  2362. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2363. var thisButton = swatchDrawer.children[i];
  2364. thisButton.textBlock.text = "b";
  2365. }
  2366. if (butEdit !== undefined) {
  2367. butEdit.textBlock.text = "Done";
  2368. }
  2369. }
  2370. else {
  2371. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2372. var thisButton = swatchDrawer.children[i];
  2373. thisButton.textBlock.text = "";
  2374. }
  2375. if (butEdit !== undefined) {
  2376. butEdit.textBlock.text = "Edit";
  2377. }
  2378. }
  2379. }
  2380. /**
  2381. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2382. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2383. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2384. * saved colors there are and how many can be stored per row.
  2385. */
  2386. function updateSwatches(color, button) {
  2387. if (options.savedColors) {
  2388. if (color != "") {
  2389. options.savedColors.push(color);
  2390. }
  2391. swatchNumber = 0;
  2392. swatchDrawer.clearControls();
  2393. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2394. if (rowCount == 0) {
  2395. var gutterCount = 0;
  2396. }
  2397. else {
  2398. var gutterCount = rowCount + 1;
  2399. }
  2400. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2401. var currentRows = swatchDrawer.rowCount;
  2402. for (var i = 0; i < currentRows; i++) {
  2403. swatchDrawer.removeRowDefinition(0);
  2404. }
  2405. for (var i = 0; i < rowCount + gutterCount; i++) {
  2406. if (i % 2) {
  2407. swatchDrawer.addRowDefinition(swatchSize, true);
  2408. }
  2409. else {
  2410. swatchDrawer.addRowDefinition(gutterSize, true);
  2411. }
  2412. }
  2413. }
  2414. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2415. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2416. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2417. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2418. var totalButtonsThisRow = options.numSwatchesPerLine;
  2419. }
  2420. else {
  2421. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2422. }
  2423. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2424. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2425. if (x > options.numSwatchesPerLine) {
  2426. continue;
  2427. }
  2428. var swatch = createSwatch();
  2429. if (swatch != null) {
  2430. swatchDrawer.addControl(swatch, y, w);
  2431. w += 2;
  2432. swatchNumber++;
  2433. }
  2434. else {
  2435. continue;
  2436. }
  2437. }
  2438. }
  2439. if (options.savedColors.length >= options.swatchLimit) {
  2440. disableButton(button, true);
  2441. }
  2442. else {
  2443. disableButton(button, false);
  2444. }
  2445. }
  2446. }
  2447. // Shows or hides edit swatches button depending on if there are saved swatches
  2448. function setEditButtonVisibility(enableButton) {
  2449. if (enableButton) {
  2450. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2451. butEdit.width = buttonWidth;
  2452. butEdit.height = buttonHeight;
  2453. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2454. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2455. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2456. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2457. butEdit.thickness = 2;
  2458. butEdit.color = buttonColor;
  2459. butEdit.fontSize = buttonFontSize;
  2460. butEdit.background = buttonBackgroundColor;
  2461. butEdit.onPointerEnterObservable.add(function () {
  2462. butEdit.background = buttonBackgroundHoverColor;
  2463. });
  2464. butEdit.onPointerOutObservable.add(function () {
  2465. butEdit.background = buttonBackgroundColor;
  2466. });
  2467. butEdit.pointerDownAnimation = function () {
  2468. butEdit.background = buttonBackgroundClickColor;
  2469. };
  2470. butEdit.pointerUpAnimation = function () {
  2471. butEdit.background = buttonBackgroundHoverColor;
  2472. };
  2473. butEdit.onPointerClickObservable.add(function () {
  2474. if (editSwatchMode) {
  2475. editSwatchMode = false;
  2476. }
  2477. else {
  2478. editSwatchMode = true;
  2479. }
  2480. editSwatches();
  2481. });
  2482. pickerGrid.addControl(butEdit, 1, 0);
  2483. }
  2484. else {
  2485. pickerGrid.removeControl(butEdit);
  2486. }
  2487. }
  2488. // Called when the user hits the limit of saved colors in the drawer.
  2489. function disableButton(button, disabled) {
  2490. if (disabled) {
  2491. button.color = buttonDisabledColor;
  2492. button.background = buttonDisabledBackgroundColor;
  2493. }
  2494. else {
  2495. button.color = buttonColor;
  2496. button.background = buttonBackgroundColor;
  2497. }
  2498. }
  2499. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2500. function closePicker(color) {
  2501. if (options.savedColors && options.savedColors.length > 0) {
  2502. resolve({
  2503. savedColors: options.savedColors,
  2504. pickedColor: color
  2505. });
  2506. }
  2507. else {
  2508. resolve({
  2509. pickedColor: color
  2510. });
  2511. }
  2512. advancedTexture.removeControl(dialogContainer);
  2513. }
  2514. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2515. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2516. dialogContainer.name = "Dialog Container";
  2517. dialogContainer.width = options.pickerWidth;
  2518. if (options.savedColors) {
  2519. dialogContainer.height = containerSize;
  2520. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2521. dialogContainer.addRowDefinition(topRow, false);
  2522. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2523. }
  2524. else {
  2525. dialogContainer.height = options.pickerHeight;
  2526. dialogContainer.addRowDefinition(1.0, false);
  2527. }
  2528. advancedTexture.addControl(dialogContainer);
  2529. // Swatch drawer which contains all saved color buttons
  2530. if (options.savedColors) {
  2531. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2532. swatchDrawer.name = "Swatch Drawer";
  2533. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2534. swatchDrawer.background = buttonBackgroundColor;
  2535. swatchDrawer.width = options.pickerWidth;
  2536. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2537. if (initialRows == 0) {
  2538. var gutterCount = 0;
  2539. }
  2540. else {
  2541. var gutterCount = initialRows + 1;
  2542. }
  2543. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2544. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2545. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2546. if (i % 2 != 0) {
  2547. swatchDrawer.addRowDefinition(swatchSize, true);
  2548. }
  2549. else {
  2550. swatchDrawer.addRowDefinition(gutterSize, true);
  2551. }
  2552. }
  2553. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2554. if (i % 2 != 0) {
  2555. swatchDrawer.addColumnDefinition(swatchSize, true);
  2556. }
  2557. else {
  2558. swatchDrawer.addColumnDefinition(gutterSize, true);
  2559. }
  2560. }
  2561. dialogContainer.addControl(swatchDrawer, 1, 0);
  2562. }
  2563. // Picker container
  2564. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2565. pickerPanel.name = "Picker Panel";
  2566. pickerPanel.height = options.pickerHeight;
  2567. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2568. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2569. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2570. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2571. dialogContainer.addControl(pickerPanel, 0, 0);
  2572. // Picker container header
  2573. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2574. header.name = "Dialogue Header Bar";
  2575. header.background = "#cccccc";
  2576. header.thickness = 0;
  2577. pickerPanel.addControl(header, 0, 0);
  2578. // Header close button
  2579. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2580. closeButton.fontFamily = "BabylonJSglyphs";
  2581. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2582. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2583. closeButton.color = closeIconColor.toHexString();
  2584. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2585. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2586. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2587. closeButton.height = closeButton.width = options.headerHeight;
  2588. closeButton.background = header.background;
  2589. closeButton.thickness = 0;
  2590. closeButton.pointerDownAnimation = function () {
  2591. };
  2592. closeButton.pointerUpAnimation = function () {
  2593. closeButton.background = header.background;
  2594. };
  2595. closeButton.pointerEnterAnimation = function () {
  2596. closeButton.color = header.background;
  2597. closeButton.background = "red";
  2598. };
  2599. closeButton.pointerOutAnimation = function () {
  2600. closeButton.color = closeIconColor.toHexString();
  2601. closeButton.background = header.background;
  2602. };
  2603. closeButton.onPointerClickObservable.add(function () {
  2604. closePicker(currentSwatch.background);
  2605. });
  2606. pickerPanel.addControl(closeButton, 0, 0);
  2607. // Dialog container body
  2608. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2609. dialogBody.name = "Dialogue Body";
  2610. dialogBody.background = buttonBackgroundColor;
  2611. var dialogBodyCols = [0.4375, 0.5625];
  2612. dialogBody.addRowDefinition(1.0, false);
  2613. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2614. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2615. pickerPanel.addControl(dialogBody, 1, 0);
  2616. // Picker grid
  2617. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2618. pickerGrid.name = "Picker Grid";
  2619. pickerGrid.addRowDefinition(0.85, false);
  2620. pickerGrid.addRowDefinition(0.15, false);
  2621. dialogBody.addControl(pickerGrid, 0, 0);
  2622. // Picker control
  2623. picker = new ColorPicker();
  2624. picker.name = "GUI Color Picker";
  2625. if (options.pickerHeight < options.pickerWidth) {
  2626. picker.width = 0.89;
  2627. }
  2628. else {
  2629. picker.height = 0.89;
  2630. }
  2631. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2632. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2633. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2634. picker.onPointerDownObservable.add(function () {
  2635. activeField = picker.name;
  2636. lastVal = "";
  2637. editSwatches(false);
  2638. });
  2639. picker.onValueChangedObservable.add(function (value) {
  2640. if (activeField == picker.name) {
  2641. updateValues(value, picker.name);
  2642. }
  2643. });
  2644. pickerGrid.addControl(picker, 0, 0);
  2645. // Picker body right quarant
  2646. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2647. pickerBodyRight.name = "Dialogue Right Half";
  2648. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2649. var pickerBodyRightRows = [0.514, 0.486];
  2650. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2651. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2652. dialogBody.addControl(pickerBodyRight, 1, 1);
  2653. // Picker container swatches and buttons
  2654. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2655. pickerSwatchesButtons.name = "Swatches and Buttons";
  2656. var pickerButtonsCol = [0.417, 0.583];
  2657. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2658. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2659. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2660. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2661. // Picker Swatches quadrant
  2662. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2663. pickerSwatches.name = "New and Current Swatches";
  2664. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2665. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2666. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2667. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2668. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2669. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2670. // Active swatches
  2671. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2672. activeSwatches.name = "Active Swatches";
  2673. activeSwatches.width = 0.67;
  2674. activeSwatches.addRowDefinition(0.5, false);
  2675. activeSwatches.addRowDefinition(0.5, false);
  2676. pickerSwatches.addControl(activeSwatches, 2, 0);
  2677. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2678. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2679. if (options.pickerWidth > options.pickerHeight) {
  2680. var labelTextSize = labelHeight;
  2681. }
  2682. else {
  2683. var labelTextSize = labelWidth;
  2684. }
  2685. // New color swatch and previous color button
  2686. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2687. newText.text = "new";
  2688. newText.name = "New Color Label";
  2689. newText.color = buttonColor;
  2690. newText.fontSize = labelTextSize;
  2691. pickerSwatches.addControl(newText, 1, 0);
  2692. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2693. newSwatch.name = "New Color Swatch";
  2694. newSwatch.background = options.lastColor;
  2695. newSwatch.thickness = 0;
  2696. activeSwatches.addControl(newSwatch, 0, 0);
  2697. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2698. currentSwatch.background = options.lastColor;
  2699. currentSwatch.thickness = 0;
  2700. currentSwatch.onPointerClickObservable.add(function () {
  2701. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2702. updateValues(revertColor, currentSwatch.name);
  2703. editSwatches(false);
  2704. });
  2705. currentSwatch.pointerDownAnimation = function () { };
  2706. currentSwatch.pointerUpAnimation = function () { };
  2707. currentSwatch.pointerEnterAnimation = function () { };
  2708. currentSwatch.pointerOutAnimation = function () { };
  2709. activeSwatches.addControl(currentSwatch, 1, 0);
  2710. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2711. swatchOutline.name = "Swatch Outline";
  2712. swatchOutline.width = 0.67;
  2713. swatchOutline.thickness = 2;
  2714. swatchOutline.color = currentSwatchesOutlineColor;
  2715. swatchOutline.isHitTestVisible = false;
  2716. pickerSwatches.addControl(swatchOutline, 2, 0);
  2717. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2718. currentText.name = "Current Color Label";
  2719. currentText.text = "current";
  2720. currentText.color = buttonColor;
  2721. currentText.fontSize = labelTextSize;
  2722. pickerSwatches.addControl(currentText, 3, 0);
  2723. // Buttons grid
  2724. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2725. buttonGrid.name = "Button Grid";
  2726. buttonGrid.height = 0.8;
  2727. var buttonGridRows = 1 / 3;
  2728. buttonGrid.addRowDefinition(buttonGridRows, false);
  2729. buttonGrid.addRowDefinition(buttonGridRows, false);
  2730. buttonGrid.addRowDefinition(buttonGridRows, false);
  2731. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2732. // Determine pixel width and height for all buttons from overall panel dimensions
  2733. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2734. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2735. // Determine button type size
  2736. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2737. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2738. }
  2739. else {
  2740. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2741. }
  2742. // Panel Buttons
  2743. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2744. butOK.width = buttonWidth;
  2745. butOK.height = buttonHeight;
  2746. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2747. butOK.thickness = 2;
  2748. butOK.color = buttonColor;
  2749. butOK.fontSize = buttonFontSize;
  2750. butOK.background = buttonBackgroundColor;
  2751. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2752. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2753. butOK.pointerDownAnimation = function () {
  2754. butOK.background = buttonBackgroundClickColor;
  2755. };
  2756. butOK.pointerUpAnimation = function () {
  2757. butOK.background = buttonBackgroundHoverColor;
  2758. };
  2759. butOK.onPointerClickObservable.add(function () {
  2760. editSwatches(false);
  2761. closePicker(newSwatch.background);
  2762. });
  2763. buttonGrid.addControl(butOK, 0, 0);
  2764. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2765. butCancel.width = buttonWidth;
  2766. butCancel.height = buttonHeight;
  2767. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2768. butCancel.thickness = 2;
  2769. butCancel.color = buttonColor;
  2770. butCancel.fontSize = buttonFontSize;
  2771. butCancel.background = buttonBackgroundColor;
  2772. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2773. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2774. butCancel.pointerDownAnimation = function () {
  2775. butCancel.background = buttonBackgroundClickColor;
  2776. };
  2777. butCancel.pointerUpAnimation = function () {
  2778. butCancel.background = buttonBackgroundHoverColor;
  2779. };
  2780. butCancel.onPointerClickObservable.add(function () {
  2781. editSwatches(false);
  2782. closePicker(currentSwatch.background);
  2783. });
  2784. buttonGrid.addControl(butCancel, 1, 0);
  2785. if (options.savedColors) {
  2786. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2787. butSave.width = buttonWidth;
  2788. butSave.height = buttonHeight;
  2789. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butSave.thickness = 2;
  2791. butSave.fontSize = buttonFontSize;
  2792. if (options.savedColors.length < options.swatchLimit) {
  2793. butSave.color = buttonColor;
  2794. butSave.background = buttonBackgroundColor;
  2795. }
  2796. else {
  2797. disableButton(butSave, true);
  2798. }
  2799. butSave.onPointerEnterObservable.add(function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundHoverColor;
  2803. }
  2804. }
  2805. });
  2806. butSave.onPointerOutObservable.add(function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundColor;
  2810. }
  2811. }
  2812. });
  2813. butSave.pointerDownAnimation = function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length < options.swatchLimit) {
  2816. butSave.background = buttonBackgroundClickColor;
  2817. }
  2818. }
  2819. };
  2820. butSave.pointerUpAnimation = function () {
  2821. if (options.savedColors) {
  2822. if (options.savedColors.length < options.swatchLimit) {
  2823. butSave.background = buttonBackgroundHoverColor;
  2824. }
  2825. }
  2826. };
  2827. butSave.onPointerClickObservable.add(function () {
  2828. if (options.savedColors) {
  2829. if (options.savedColors.length == 0) {
  2830. setEditButtonVisibility(true);
  2831. }
  2832. if (options.savedColors.length < options.swatchLimit) {
  2833. updateSwatches(newSwatch.background, butSave);
  2834. }
  2835. editSwatches(false);
  2836. }
  2837. });
  2838. if (options.savedColors.length > 0) {
  2839. setEditButtonVisibility(true);
  2840. }
  2841. buttonGrid.addControl(butSave, 2, 0);
  2842. }
  2843. // Picker color values input
  2844. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2845. pickerColorValues.name = "Dialog Lower Right";
  2846. pickerColorValues.addRowDefinition(0.02, false);
  2847. pickerColorValues.addRowDefinition(0.63, false);
  2848. pickerColorValues.addRowDefinition(0.21, false);
  2849. pickerColorValues.addRowDefinition(0.14, false);
  2850. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2851. // RGB values text boxes
  2852. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2853. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2854. rgbValuesQuadrant.name = "RGB Values";
  2855. rgbValuesQuadrant.width = 0.82;
  2856. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2857. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2858. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2859. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2860. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2861. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2862. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2863. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2864. for (var i = 0; i < inputFieldLabels.length; i++) {
  2865. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2866. labelText.text = inputFieldLabels[i];
  2867. labelText.color = buttonColor;
  2868. labelText.fontSize = buttonFontSize;
  2869. rgbValuesQuadrant.addControl(labelText, i, 0);
  2870. }
  2871. // Input fields for RGB values
  2872. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2873. rValInt.width = 0.83;
  2874. rValInt.height = 0.72;
  2875. rValInt.name = "rIntField";
  2876. rValInt.fontSize = buttonFontSize;
  2877. rValInt.text = (currentColor.r * 255).toString();
  2878. rValInt.color = inputTextColor;
  2879. rValInt.background = inputTextBackgroundColor;
  2880. rValInt.onFocusObservable.add(function () {
  2881. activeField = rValInt.name;
  2882. lastVal = rValInt.text;
  2883. editSwatches(false);
  2884. });
  2885. rValInt.onBlurObservable.add(function () {
  2886. if (rValInt.text == "") {
  2887. rValInt.text = "0";
  2888. }
  2889. updateInt(rValInt, "r");
  2890. if (activeField == rValInt.name) {
  2891. activeField = "";
  2892. }
  2893. });
  2894. rValInt.onTextChangedObservable.add(function () {
  2895. if (activeField == rValInt.name) {
  2896. updateInt(rValInt, "r");
  2897. }
  2898. });
  2899. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2900. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2901. gValInt.width = 0.83;
  2902. gValInt.height = 0.72;
  2903. gValInt.name = "gIntField";
  2904. gValInt.fontSize = buttonFontSize;
  2905. gValInt.text = (currentColor.g * 255).toString();
  2906. gValInt.color = inputTextColor;
  2907. gValInt.background = inputTextBackgroundColor;
  2908. gValInt.onFocusObservable.add(function () {
  2909. activeField = gValInt.name;
  2910. lastVal = gValInt.text;
  2911. editSwatches(false);
  2912. });
  2913. gValInt.onBlurObservable.add(function () {
  2914. if (gValInt.text == "") {
  2915. gValInt.text = "0";
  2916. }
  2917. updateInt(gValInt, "g");
  2918. if (activeField == gValInt.name) {
  2919. activeField = "";
  2920. }
  2921. });
  2922. gValInt.onTextChangedObservable.add(function () {
  2923. if (activeField == gValInt.name) {
  2924. updateInt(gValInt, "g");
  2925. }
  2926. });
  2927. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2928. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2929. bValInt.width = 0.83;
  2930. bValInt.height = 0.72;
  2931. bValInt.name = "bIntField";
  2932. bValInt.fontSize = buttonFontSize;
  2933. bValInt.text = (currentColor.b * 255).toString();
  2934. bValInt.color = inputTextColor;
  2935. bValInt.background = inputTextBackgroundColor;
  2936. bValInt.onFocusObservable.add(function () {
  2937. activeField = bValInt.name;
  2938. lastVal = bValInt.text;
  2939. editSwatches(false);
  2940. });
  2941. bValInt.onBlurObservable.add(function () {
  2942. if (bValInt.text == "") {
  2943. bValInt.text = "0";
  2944. }
  2945. updateInt(bValInt, "b");
  2946. if (activeField == bValInt.name) {
  2947. activeField = "";
  2948. }
  2949. });
  2950. bValInt.onTextChangedObservable.add(function () {
  2951. if (activeField == bValInt.name) {
  2952. updateInt(bValInt, "b");
  2953. }
  2954. });
  2955. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2956. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2957. rValDec.width = 0.95;
  2958. rValDec.height = 0.72;
  2959. rValDec.name = "rDecField";
  2960. rValDec.fontSize = buttonFontSize;
  2961. rValDec.text = currentColor.r.toString();
  2962. rValDec.color = inputTextColor;
  2963. rValDec.background = inputTextBackgroundColor;
  2964. rValDec.onFocusObservable.add(function () {
  2965. activeField = rValDec.name;
  2966. lastVal = rValDec.text;
  2967. editSwatches(false);
  2968. });
  2969. rValDec.onBlurObservable.add(function () {
  2970. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2971. rValDec.text = "0";
  2972. updateFloat(rValDec, "r");
  2973. }
  2974. if (activeField == rValDec.name) {
  2975. activeField = "";
  2976. }
  2977. });
  2978. rValDec.onTextChangedObservable.add(function () {
  2979. if (activeField == rValDec.name) {
  2980. updateFloat(rValDec, "r");
  2981. }
  2982. });
  2983. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2984. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2985. gValDec.width = 0.95;
  2986. gValDec.height = 0.72;
  2987. gValDec.name = "gDecField";
  2988. gValDec.fontSize = buttonFontSize;
  2989. gValDec.text = currentColor.g.toString();
  2990. gValDec.color = inputTextColor;
  2991. gValDec.background = inputTextBackgroundColor;
  2992. gValDec.onFocusObservable.add(function () {
  2993. activeField = gValDec.name;
  2994. lastVal = gValDec.text;
  2995. editSwatches(false);
  2996. });
  2997. gValDec.onBlurObservable.add(function () {
  2998. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2999. gValDec.text = "0";
  3000. updateFloat(gValDec, "g");
  3001. }
  3002. if (activeField == gValDec.name) {
  3003. activeField = "";
  3004. }
  3005. });
  3006. gValDec.onTextChangedObservable.add(function () {
  3007. if (activeField == gValDec.name) {
  3008. updateFloat(gValDec, "g");
  3009. }
  3010. });
  3011. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3012. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3013. bValDec.width = 0.95;
  3014. bValDec.height = 0.72;
  3015. bValDec.name = "bDecField";
  3016. bValDec.fontSize = buttonFontSize;
  3017. bValDec.text = currentColor.b.toString();
  3018. bValDec.color = inputTextColor;
  3019. bValDec.background = inputTextBackgroundColor;
  3020. bValDec.onFocusObservable.add(function () {
  3021. activeField = bValDec.name;
  3022. lastVal = bValDec.text;
  3023. editSwatches(false);
  3024. });
  3025. bValDec.onBlurObservable.add(function () {
  3026. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3027. bValDec.text = "0";
  3028. updateFloat(bValDec, "b");
  3029. }
  3030. if (activeField == bValDec.name) {
  3031. activeField = "";
  3032. }
  3033. });
  3034. bValDec.onTextChangedObservable.add(function () {
  3035. if (activeField == bValDec.name) {
  3036. updateFloat(bValDec, "b");
  3037. }
  3038. });
  3039. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3040. // Hex value input
  3041. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3042. hexValueQuadrant.name = "Hex Value";
  3043. hexValueQuadrant.width = 0.82;
  3044. hexValueQuadrant.addRowDefinition(1.0, false);
  3045. hexValueQuadrant.addColumnDefinition(0.1, false);
  3046. hexValueQuadrant.addColumnDefinition(0.9, false);
  3047. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3048. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3049. labelText.text = "#";
  3050. labelText.color = buttonColor;
  3051. labelText.fontSize = buttonFontSize;
  3052. hexValueQuadrant.addControl(labelText, 0, 0);
  3053. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3054. hexVal.width = 0.96;
  3055. hexVal.height = 0.72;
  3056. hexVal.name = "hexField";
  3057. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3058. hexVal.fontSize = buttonFontSize;
  3059. var minusPound = options.lastColor.split("#");
  3060. hexVal.text = minusPound[1];
  3061. hexVal.color = inputTextColor;
  3062. hexVal.background = inputTextBackgroundColor;
  3063. hexVal.onFocusObservable.add(function () {
  3064. activeField = hexVal.name;
  3065. lastVal = hexVal.text;
  3066. editSwatches(false);
  3067. });
  3068. hexVal.onBlurObservable.add(function () {
  3069. if (hexVal.text.length == 3) {
  3070. var val = hexVal.text.split("");
  3071. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3072. }
  3073. if (hexVal.text == "") {
  3074. hexVal.text = "000000";
  3075. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3076. }
  3077. if (activeField == hexVal.name) {
  3078. activeField = "";
  3079. }
  3080. });
  3081. hexVal.onTextChangedObservable.add(function () {
  3082. var newHexValue = hexVal.text;
  3083. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3084. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3085. hexVal.text = lastVal;
  3086. }
  3087. else {
  3088. if (hexVal.text.length < 6) {
  3089. var leadingZero = 6 - hexVal.text.length;
  3090. for (var i = 0; i < leadingZero; i++) {
  3091. newHexValue = "0" + newHexValue;
  3092. }
  3093. }
  3094. if (hexVal.text.length == 3) {
  3095. var val = hexVal.text.split("");
  3096. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3097. }
  3098. newHexValue = "#" + newHexValue;
  3099. if (activeField == hexVal.name) {
  3100. lastVal = hexVal.text;
  3101. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3102. }
  3103. }
  3104. });
  3105. hexValueQuadrant.addControl(hexVal, 0, 1);
  3106. if (options.savedColors && options.savedColors.length > 0) {
  3107. updateSwatches("", butSave);
  3108. }
  3109. });
  3110. };
  3111. ColorPicker._Epsilon = 0.000001;
  3112. return ColorPicker;
  3113. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3114. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3115. /***/ }),
  3116. /***/ "./2D/controls/container.ts":
  3117. /*!**********************************!*\
  3118. !*** ./2D/controls/container.ts ***!
  3119. \**********************************/
  3120. /*! exports provided: Container */
  3121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3122. "use strict";
  3123. __webpack_require__.r(__webpack_exports__);
  3124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3126. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math");
  3127. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3128. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3129. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3130. /**
  3131. * Root class for 2D containers
  3132. * @see http://doc.babylonjs.com/how_to/gui#containers
  3133. */
  3134. var Container = /** @class */ (function (_super) {
  3135. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3136. /**
  3137. * Creates a new Container
  3138. * @param name defines the name of the container
  3139. */
  3140. function Container(name) {
  3141. var _this = _super.call(this, name) || this;
  3142. _this.name = name;
  3143. /** @hidden */
  3144. _this._children = new Array();
  3145. /** @hidden */
  3146. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3147. /** @hidden */
  3148. _this._background = "";
  3149. /** @hidden */
  3150. _this._adaptWidthToChildren = false;
  3151. /** @hidden */
  3152. _this._adaptHeightToChildren = false;
  3153. /**
  3154. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3155. */
  3156. _this.logLayoutCycleErrors = false;
  3157. /**
  3158. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3159. */
  3160. _this.maxLayoutCycle = 3;
  3161. return _this;
  3162. }
  3163. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3164. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3165. get: function () {
  3166. return this._adaptHeightToChildren;
  3167. },
  3168. set: function (value) {
  3169. if (this._adaptHeightToChildren === value) {
  3170. return;
  3171. }
  3172. this._adaptHeightToChildren = value;
  3173. if (value) {
  3174. this.height = "100%";
  3175. }
  3176. this._markAsDirty();
  3177. },
  3178. enumerable: true,
  3179. configurable: true
  3180. });
  3181. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3182. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3183. get: function () {
  3184. return this._adaptWidthToChildren;
  3185. },
  3186. set: function (value) {
  3187. if (this._adaptWidthToChildren === value) {
  3188. return;
  3189. }
  3190. this._adaptWidthToChildren = value;
  3191. if (value) {
  3192. this.width = "100%";
  3193. }
  3194. this._markAsDirty();
  3195. },
  3196. enumerable: true,
  3197. configurable: true
  3198. });
  3199. Object.defineProperty(Container.prototype, "background", {
  3200. /** Gets or sets background color */
  3201. get: function () {
  3202. return this._background;
  3203. },
  3204. set: function (value) {
  3205. if (this._background === value) {
  3206. return;
  3207. }
  3208. this._background = value;
  3209. this._markAsDirty();
  3210. },
  3211. enumerable: true,
  3212. configurable: true
  3213. });
  3214. Object.defineProperty(Container.prototype, "children", {
  3215. /** Gets the list of children */
  3216. get: function () {
  3217. return this._children;
  3218. },
  3219. enumerable: true,
  3220. configurable: true
  3221. });
  3222. Container.prototype._getTypeName = function () {
  3223. return "Container";
  3224. };
  3225. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3226. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3227. var child = _a[_i];
  3228. child._markMatrixAsDirty();
  3229. }
  3230. };
  3231. /**
  3232. * Gets a child using its name
  3233. * @param name defines the child name to look for
  3234. * @returns the child control if found
  3235. */
  3236. Container.prototype.getChildByName = function (name) {
  3237. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3238. var child = _a[_i];
  3239. if (child.name === name) {
  3240. return child;
  3241. }
  3242. }
  3243. return null;
  3244. };
  3245. /**
  3246. * Gets a child using its type and its name
  3247. * @param name defines the child name to look for
  3248. * @param type defines the child type to look for
  3249. * @returns the child control if found
  3250. */
  3251. Container.prototype.getChildByType = function (name, type) {
  3252. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3253. var child = _a[_i];
  3254. if (child.typeName === type) {
  3255. return child;
  3256. }
  3257. }
  3258. return null;
  3259. };
  3260. /**
  3261. * Search for a specific control in children
  3262. * @param control defines the control to look for
  3263. * @returns true if the control is in child list
  3264. */
  3265. Container.prototype.containsControl = function (control) {
  3266. return this.children.indexOf(control) !== -1;
  3267. };
  3268. /**
  3269. * Adds a new control to the current container
  3270. * @param control defines the control to add
  3271. * @returns the current container
  3272. */
  3273. Container.prototype.addControl = function (control) {
  3274. if (!control) {
  3275. return this;
  3276. }
  3277. var index = this._children.indexOf(control);
  3278. if (index !== -1) {
  3279. return this;
  3280. }
  3281. control._link(this._host);
  3282. control._markAllAsDirty();
  3283. this._reOrderControl(control);
  3284. this._markAsDirty();
  3285. return this;
  3286. };
  3287. /**
  3288. * Removes all controls from the current container
  3289. * @returns the current container
  3290. */
  3291. Container.prototype.clearControls = function () {
  3292. var children = this.children.slice();
  3293. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3294. var child = children_1[_i];
  3295. this.removeControl(child);
  3296. }
  3297. return this;
  3298. };
  3299. /**
  3300. * Removes a control from the current container
  3301. * @param control defines the control to remove
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.removeControl = function (control) {
  3305. var index = this._children.indexOf(control);
  3306. if (index !== -1) {
  3307. this._children.splice(index, 1);
  3308. control.parent = null;
  3309. }
  3310. control.linkWithMesh(null);
  3311. if (this._host) {
  3312. this._host._cleanControlAfterRemoval(control);
  3313. }
  3314. this._markAsDirty();
  3315. return this;
  3316. };
  3317. /** @hidden */
  3318. Container.prototype._reOrderControl = function (control) {
  3319. this.removeControl(control);
  3320. var wasAdded = false;
  3321. for (var index = 0; index < this._children.length; index++) {
  3322. if (this._children[index].zIndex > control.zIndex) {
  3323. this._children.splice(index, 0, control);
  3324. wasAdded = true;
  3325. break;
  3326. }
  3327. }
  3328. if (!wasAdded) {
  3329. this._children.push(control);
  3330. }
  3331. control.parent = this;
  3332. this._markAsDirty();
  3333. };
  3334. /** @hidden */
  3335. Container.prototype._offsetLeft = function (offset) {
  3336. _super.prototype._offsetLeft.call(this, offset);
  3337. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3338. var child = _a[_i];
  3339. child._offsetLeft(offset);
  3340. }
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._offsetTop = function (offset) {
  3344. _super.prototype._offsetTop.call(this, offset);
  3345. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3346. var child = _a[_i];
  3347. child._offsetTop(offset);
  3348. }
  3349. };
  3350. /** @hidden */
  3351. Container.prototype._markAllAsDirty = function () {
  3352. _super.prototype._markAllAsDirty.call(this);
  3353. for (var index = 0; index < this._children.length; index++) {
  3354. this._children[index]._markAllAsDirty();
  3355. }
  3356. };
  3357. /** @hidden */
  3358. Container.prototype._localDraw = function (context) {
  3359. if (this._background) {
  3360. context.save();
  3361. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3362. context.shadowColor = this.shadowColor;
  3363. context.shadowBlur = this.shadowBlur;
  3364. context.shadowOffsetX = this.shadowOffsetX;
  3365. context.shadowOffsetY = this.shadowOffsetY;
  3366. }
  3367. context.fillStyle = this._background;
  3368. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3369. context.restore();
  3370. }
  3371. };
  3372. /** @hidden */
  3373. Container.prototype._link = function (host) {
  3374. _super.prototype._link.call(this, host);
  3375. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3376. var child = _a[_i];
  3377. child._link(host);
  3378. }
  3379. };
  3380. /** @hidden */
  3381. Container.prototype._beforeLayout = function () {
  3382. // Do nothing
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._processMeasures = function (parentMeasure, context) {
  3386. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3387. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3388. this._evaluateClippingState(parentMeasure);
  3389. }
  3390. };
  3391. /** @hidden */
  3392. Container.prototype._layout = function (parentMeasure, context) {
  3393. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3394. return false;
  3395. }
  3396. if (this._isDirty) {
  3397. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3398. }
  3399. var rebuildCount = 0;
  3400. context.save();
  3401. this._applyStates(context);
  3402. this._beforeLayout();
  3403. do {
  3404. var computedWidth = -1;
  3405. var computedHeight = -1;
  3406. this._rebuildLayout = false;
  3407. this._processMeasures(parentMeasure, context);
  3408. if (!this._isClipped) {
  3409. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3410. var child = _a[_i];
  3411. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3412. if (child._layout(this._measureForChildren, context)) {
  3413. if (this.adaptWidthToChildren && child._width.isPixel) {
  3414. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3415. }
  3416. if (this.adaptHeightToChildren && child._height.isPixel) {
  3417. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3418. }
  3419. }
  3420. }
  3421. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3422. if (this.width !== computedWidth + "px") {
  3423. this.width = computedWidth + "px";
  3424. this._rebuildLayout = true;
  3425. }
  3426. }
  3427. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3428. if (this.height !== computedHeight + "px") {
  3429. this.height = computedHeight + "px";
  3430. this._rebuildLayout = true;
  3431. }
  3432. }
  3433. this._postMeasure();
  3434. }
  3435. rebuildCount++;
  3436. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3437. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3438. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3439. }
  3440. context.restore();
  3441. if (this._isDirty) {
  3442. this.invalidateRect();
  3443. this._isDirty = false;
  3444. }
  3445. return true;
  3446. };
  3447. Container.prototype._postMeasure = function () {
  3448. // Do nothing by default
  3449. };
  3450. /** @hidden */
  3451. Container.prototype._draw = function (context, invalidatedRectangle) {
  3452. this._localDraw(context);
  3453. if (this.clipChildren) {
  3454. this._clipForChildren(context);
  3455. }
  3456. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3457. var child = _a[_i];
  3458. // Only redraw parts of the screen that are invalidated
  3459. if (invalidatedRectangle) {
  3460. if (!child._intersectsRect(invalidatedRectangle)) {
  3461. continue;
  3462. }
  3463. }
  3464. child._render(context, invalidatedRectangle);
  3465. }
  3466. };
  3467. /** @hidden */
  3468. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3469. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3470. if (!this.children) {
  3471. return;
  3472. }
  3473. for (var index = 0; index < this.children.length; index++) {
  3474. var item = this.children[index];
  3475. if (!predicate || predicate(item)) {
  3476. results.push(item);
  3477. }
  3478. if (!directDescendantsOnly) {
  3479. item._getDescendants(results, false, predicate);
  3480. }
  3481. }
  3482. };
  3483. /** @hidden */
  3484. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3485. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3486. return false;
  3487. }
  3488. if (!_super.prototype.contains.call(this, x, y)) {
  3489. return false;
  3490. }
  3491. // Checking backwards to pick closest first
  3492. for (var index = this._children.length - 1; index >= 0; index--) {
  3493. var child = this._children[index];
  3494. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3495. if (child.hoverCursor) {
  3496. this._host._changeCursor(child.hoverCursor);
  3497. }
  3498. return true;
  3499. }
  3500. }
  3501. if (!this.isHitTestVisible) {
  3502. return false;
  3503. }
  3504. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3505. };
  3506. /** @hidden */
  3507. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3508. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3509. this._measureForChildren.copyFrom(this._currentMeasure);
  3510. };
  3511. /** Releases associated resources */
  3512. Container.prototype.dispose = function () {
  3513. _super.prototype.dispose.call(this);
  3514. for (var index = this.children.length - 1; index >= 0; index--) {
  3515. this.children[index].dispose();
  3516. }
  3517. };
  3518. return Container;
  3519. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3520. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3521. /***/ }),
  3522. /***/ "./2D/controls/control.ts":
  3523. /*!********************************!*\
  3524. !*** ./2D/controls/control.ts ***!
  3525. \********************************/
  3526. /*! exports provided: Control */
  3527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3528. "use strict";
  3529. __webpack_require__.r(__webpack_exports__);
  3530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3531. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3532. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3533. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3534. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3535. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3536. /**
  3537. * Root class used for all 2D controls
  3538. * @see http://doc.babylonjs.com/how_to/gui#controls
  3539. */
  3540. var Control = /** @class */ (function () {
  3541. // Functions
  3542. /**
  3543. * Creates a new control
  3544. * @param name defines the name of the control
  3545. */
  3546. function Control(
  3547. /** defines the name of the control */
  3548. name) {
  3549. this.name = name;
  3550. this._alpha = 1;
  3551. this._alphaSet = false;
  3552. this._zIndex = 0;
  3553. /** @hidden */
  3554. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3555. this._fontFamily = "Arial";
  3556. this._fontStyle = "";
  3557. this._fontWeight = "";
  3558. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3559. /** @hidden */
  3560. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3561. /** @hidden */
  3562. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3563. this._color = "";
  3564. this._style = null;
  3565. /** @hidden */
  3566. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3567. /** @hidden */
  3568. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3569. /** @hidden */
  3570. this._isDirty = true;
  3571. /** @hidden */
  3572. this._wasDirty = false;
  3573. /** @hidden */
  3574. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3575. /** @hidden */
  3576. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3577. /** @hidden */
  3578. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3579. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3580. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3582. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3583. /** @hidden */
  3584. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3585. /** @hidden */
  3586. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3587. this._scaleX = 1.0;
  3588. this._scaleY = 1.0;
  3589. this._rotation = 0;
  3590. this._transformCenterX = 0.5;
  3591. this._transformCenterY = 0.5;
  3592. /** @hidden */
  3593. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3594. /** @hidden */
  3595. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3596. /** @hidden */
  3597. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3598. this._isMatrixDirty = true;
  3599. this._isVisible = true;
  3600. this._isHighlighted = false;
  3601. this._fontSet = false;
  3602. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3603. this._downCount = 0;
  3604. this._enterCount = -1;
  3605. this._doNotRender = false;
  3606. this._downPointerIds = {};
  3607. this._isEnabled = true;
  3608. this._disabledColor = "#9a9a9a";
  3609. /** @hidden */
  3610. this._rebuildLayout = false;
  3611. /** @hidden */
  3612. this._isClipped = false;
  3613. /**
  3614. * Gets or sets an object used to store user defined information for the node
  3615. */
  3616. this.metadata = null;
  3617. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3618. this.isHitTestVisible = true;
  3619. /** Gets or sets a boolean indicating if the control can block pointer events */
  3620. this.isPointerBlocker = false;
  3621. /** Gets or sets a boolean indicating if the control can be focusable */
  3622. this.isFocusInvisible = false;
  3623. /**
  3624. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3625. * 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
  3626. */
  3627. this.clipChildren = true;
  3628. /**
  3629. * Gets or sets a boolean indicating that control content must be clipped
  3630. * 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
  3631. */
  3632. this.clipContent = true;
  3633. /**
  3634. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3635. */
  3636. this.useBitmapCache = false;
  3637. this._shadowOffsetX = 0;
  3638. this._shadowOffsetY = 0;
  3639. this._shadowBlur = 0;
  3640. this._shadowColor = 'black';
  3641. /** Gets or sets the cursor to use when the control is hovered */
  3642. this.hoverCursor = "";
  3643. /** @hidden */
  3644. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3645. /** @hidden */
  3646. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3647. /**
  3648. * An event triggered when the pointer move over the control.
  3649. */
  3650. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3651. /**
  3652. * An event triggered when the pointer move out of the control.
  3653. */
  3654. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3655. /**
  3656. * An event triggered when the pointer taps the control
  3657. */
  3658. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3659. /**
  3660. * An event triggered when pointer up
  3661. */
  3662. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3663. /**
  3664. * An event triggered when a control is clicked on
  3665. */
  3666. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3667. /**
  3668. * An event triggered when pointer enters the control
  3669. */
  3670. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3671. /**
  3672. * An event triggered when the control is marked as dirty
  3673. */
  3674. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3675. /**
  3676. * An event triggered before drawing the control
  3677. */
  3678. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3679. /**
  3680. * An event triggered after the control was drawn
  3681. */
  3682. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3683. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3684. }
  3685. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3686. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3687. get: function () {
  3688. return this._shadowOffsetX;
  3689. },
  3690. set: function (value) {
  3691. if (this._shadowOffsetX === value) {
  3692. return;
  3693. }
  3694. this._shadowOffsetX = value;
  3695. this._markAsDirty();
  3696. },
  3697. enumerable: true,
  3698. configurable: true
  3699. });
  3700. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3701. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3702. get: function () {
  3703. return this._shadowOffsetY;
  3704. },
  3705. set: function (value) {
  3706. if (this._shadowOffsetY === value) {
  3707. return;
  3708. }
  3709. this._shadowOffsetY = value;
  3710. this._markAsDirty();
  3711. },
  3712. enumerable: true,
  3713. configurable: true
  3714. });
  3715. Object.defineProperty(Control.prototype, "shadowBlur", {
  3716. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3717. get: function () {
  3718. return this._shadowBlur;
  3719. },
  3720. set: function (value) {
  3721. if (this._shadowBlur === value) {
  3722. return;
  3723. }
  3724. this._shadowBlur = value;
  3725. this._markAsDirty();
  3726. },
  3727. enumerable: true,
  3728. configurable: true
  3729. });
  3730. Object.defineProperty(Control.prototype, "shadowColor", {
  3731. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3732. get: function () {
  3733. return this._shadowColor;
  3734. },
  3735. set: function (value) {
  3736. if (this._shadowColor === value) {
  3737. return;
  3738. }
  3739. this._shadowColor = value;
  3740. this._markAsDirty();
  3741. },
  3742. enumerable: true,
  3743. configurable: true
  3744. });
  3745. Object.defineProperty(Control.prototype, "typeName", {
  3746. // Properties
  3747. /** Gets the control type name */
  3748. get: function () {
  3749. return this._getTypeName();
  3750. },
  3751. enumerable: true,
  3752. configurable: true
  3753. });
  3754. /**
  3755. * Get the current class name of the control.
  3756. * @returns current class name
  3757. */
  3758. Control.prototype.getClassName = function () {
  3759. return this._getTypeName();
  3760. };
  3761. Object.defineProperty(Control.prototype, "host", {
  3762. /**
  3763. * Get the hosting AdvancedDynamicTexture
  3764. */
  3765. get: function () {
  3766. return this._host;
  3767. },
  3768. enumerable: true,
  3769. configurable: true
  3770. });
  3771. Object.defineProperty(Control.prototype, "fontOffset", {
  3772. /** Gets or set information about font offsets (used to render and align text) */
  3773. get: function () {
  3774. return this._fontOffset;
  3775. },
  3776. set: function (offset) {
  3777. this._fontOffset = offset;
  3778. },
  3779. enumerable: true,
  3780. configurable: true
  3781. });
  3782. Object.defineProperty(Control.prototype, "alpha", {
  3783. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3784. get: function () {
  3785. return this._alpha;
  3786. },
  3787. set: function (value) {
  3788. if (this._alpha === value) {
  3789. return;
  3790. }
  3791. this._alphaSet = true;
  3792. this._alpha = value;
  3793. this._markAsDirty();
  3794. },
  3795. enumerable: true,
  3796. configurable: true
  3797. });
  3798. Object.defineProperty(Control.prototype, "isHighlighted", {
  3799. /**
  3800. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3801. */
  3802. get: function () {
  3803. return this._isHighlighted;
  3804. },
  3805. set: function (value) {
  3806. if (this._isHighlighted === value) {
  3807. return;
  3808. }
  3809. this._isHighlighted = value;
  3810. this._markAsDirty();
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Control.prototype, "scaleX", {
  3816. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3817. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3818. */
  3819. get: function () {
  3820. return this._scaleX;
  3821. },
  3822. set: function (value) {
  3823. if (this._scaleX === value) {
  3824. return;
  3825. }
  3826. this._scaleX = value;
  3827. this._markAsDirty();
  3828. this._markMatrixAsDirty();
  3829. },
  3830. enumerable: true,
  3831. configurable: true
  3832. });
  3833. Object.defineProperty(Control.prototype, "scaleY", {
  3834. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3835. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3836. */
  3837. get: function () {
  3838. return this._scaleY;
  3839. },
  3840. set: function (value) {
  3841. if (this._scaleY === value) {
  3842. return;
  3843. }
  3844. this._scaleY = value;
  3845. this._markAsDirty();
  3846. this._markMatrixAsDirty();
  3847. },
  3848. enumerable: true,
  3849. configurable: true
  3850. });
  3851. Object.defineProperty(Control.prototype, "rotation", {
  3852. /** Gets or sets the rotation angle (0 by default)
  3853. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3854. */
  3855. get: function () {
  3856. return this._rotation;
  3857. },
  3858. set: function (value) {
  3859. if (this._rotation === value) {
  3860. return;
  3861. }
  3862. this._rotation = value;
  3863. this._markAsDirty();
  3864. this._markMatrixAsDirty();
  3865. },
  3866. enumerable: true,
  3867. configurable: true
  3868. });
  3869. Object.defineProperty(Control.prototype, "transformCenterY", {
  3870. /** Gets or sets the transformation center on Y axis (0 by default)
  3871. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3872. */
  3873. get: function () {
  3874. return this._transformCenterY;
  3875. },
  3876. set: function (value) {
  3877. if (this._transformCenterY === value) {
  3878. return;
  3879. }
  3880. this._transformCenterY = value;
  3881. this._markAsDirty();
  3882. this._markMatrixAsDirty();
  3883. },
  3884. enumerable: true,
  3885. configurable: true
  3886. });
  3887. Object.defineProperty(Control.prototype, "transformCenterX", {
  3888. /** Gets or sets the transformation center on X axis (0 by default)
  3889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3890. */
  3891. get: function () {
  3892. return this._transformCenterX;
  3893. },
  3894. set: function (value) {
  3895. if (this._transformCenterX === value) {
  3896. return;
  3897. }
  3898. this._transformCenterX = value;
  3899. this._markAsDirty();
  3900. this._markMatrixAsDirty();
  3901. },
  3902. enumerable: true,
  3903. configurable: true
  3904. });
  3905. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3906. /**
  3907. * Gets or sets the horizontal alignment
  3908. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3909. */
  3910. get: function () {
  3911. return this._horizontalAlignment;
  3912. },
  3913. set: function (value) {
  3914. if (this._horizontalAlignment === value) {
  3915. return;
  3916. }
  3917. this._horizontalAlignment = value;
  3918. this._markAsDirty();
  3919. },
  3920. enumerable: true,
  3921. configurable: true
  3922. });
  3923. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3924. /**
  3925. * Gets or sets the vertical alignment
  3926. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3927. */
  3928. get: function () {
  3929. return this._verticalAlignment;
  3930. },
  3931. set: function (value) {
  3932. if (this._verticalAlignment === value) {
  3933. return;
  3934. }
  3935. this._verticalAlignment = value;
  3936. this._markAsDirty();
  3937. },
  3938. enumerable: true,
  3939. configurable: true
  3940. });
  3941. Object.defineProperty(Control.prototype, "width", {
  3942. /**
  3943. * Gets or sets control width
  3944. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3945. */
  3946. get: function () {
  3947. return this._width.toString(this._host);
  3948. },
  3949. set: function (value) {
  3950. if (this._width.toString(this._host) === value) {
  3951. return;
  3952. }
  3953. if (this._width.fromString(value)) {
  3954. this._markAsDirty();
  3955. }
  3956. },
  3957. enumerable: true,
  3958. configurable: true
  3959. });
  3960. Object.defineProperty(Control.prototype, "widthInPixels", {
  3961. /**
  3962. * Gets or sets the control width in pixel
  3963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3964. */
  3965. get: function () {
  3966. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3967. },
  3968. set: function (value) {
  3969. if (isNaN(value)) {
  3970. return;
  3971. }
  3972. this.width = value + "px";
  3973. },
  3974. enumerable: true,
  3975. configurable: true
  3976. });
  3977. Object.defineProperty(Control.prototype, "height", {
  3978. /**
  3979. * Gets or sets control height
  3980. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3981. */
  3982. get: function () {
  3983. return this._height.toString(this._host);
  3984. },
  3985. set: function (value) {
  3986. if (this._height.toString(this._host) === value) {
  3987. return;
  3988. }
  3989. if (this._height.fromString(value)) {
  3990. this._markAsDirty();
  3991. }
  3992. },
  3993. enumerable: true,
  3994. configurable: true
  3995. });
  3996. Object.defineProperty(Control.prototype, "heightInPixels", {
  3997. /**
  3998. * Gets or sets control height in pixel
  3999. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4000. */
  4001. get: function () {
  4002. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4003. },
  4004. set: function (value) {
  4005. if (isNaN(value)) {
  4006. return;
  4007. }
  4008. this.height = value + "px";
  4009. },
  4010. enumerable: true,
  4011. configurable: true
  4012. });
  4013. Object.defineProperty(Control.prototype, "fontFamily", {
  4014. /** Gets or set font family */
  4015. get: function () {
  4016. if (!this._fontSet) {
  4017. return "";
  4018. }
  4019. return this._fontFamily;
  4020. },
  4021. set: function (value) {
  4022. if (this._fontFamily === value) {
  4023. return;
  4024. }
  4025. this._fontFamily = value;
  4026. this._resetFontCache();
  4027. },
  4028. enumerable: true,
  4029. configurable: true
  4030. });
  4031. Object.defineProperty(Control.prototype, "fontStyle", {
  4032. /** Gets or sets font style */
  4033. get: function () {
  4034. return this._fontStyle;
  4035. },
  4036. set: function (value) {
  4037. if (this._fontStyle === value) {
  4038. return;
  4039. }
  4040. this._fontStyle = value;
  4041. this._resetFontCache();
  4042. },
  4043. enumerable: true,
  4044. configurable: true
  4045. });
  4046. Object.defineProperty(Control.prototype, "fontWeight", {
  4047. /** Gets or sets font weight */
  4048. get: function () {
  4049. return this._fontWeight;
  4050. },
  4051. set: function (value) {
  4052. if (this._fontWeight === value) {
  4053. return;
  4054. }
  4055. this._fontWeight = value;
  4056. this._resetFontCache();
  4057. },
  4058. enumerable: true,
  4059. configurable: true
  4060. });
  4061. Object.defineProperty(Control.prototype, "style", {
  4062. /**
  4063. * Gets or sets style
  4064. * @see http://doc.babylonjs.com/how_to/gui#styles
  4065. */
  4066. get: function () {
  4067. return this._style;
  4068. },
  4069. set: function (value) {
  4070. var _this = this;
  4071. if (this._style) {
  4072. this._style.onChangedObservable.remove(this._styleObserver);
  4073. this._styleObserver = null;
  4074. }
  4075. this._style = value;
  4076. if (this._style) {
  4077. this._styleObserver = this._style.onChangedObservable.add(function () {
  4078. _this._markAsDirty();
  4079. _this._resetFontCache();
  4080. });
  4081. }
  4082. this._markAsDirty();
  4083. this._resetFontCache();
  4084. },
  4085. enumerable: true,
  4086. configurable: true
  4087. });
  4088. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4089. /** @hidden */
  4090. get: function () {
  4091. return this._fontSize.isPercentage;
  4092. },
  4093. enumerable: true,
  4094. configurable: true
  4095. });
  4096. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4097. /** Gets or sets font size in pixels */
  4098. get: function () {
  4099. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4100. if (fontSizeToUse.isPixel) {
  4101. return fontSizeToUse.getValue(this._host);
  4102. }
  4103. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4104. },
  4105. set: function (value) {
  4106. if (isNaN(value)) {
  4107. return;
  4108. }
  4109. this.fontSize = value + "px";
  4110. },
  4111. enumerable: true,
  4112. configurable: true
  4113. });
  4114. Object.defineProperty(Control.prototype, "fontSize", {
  4115. /** Gets or sets font size */
  4116. get: function () {
  4117. return this._fontSize.toString(this._host);
  4118. },
  4119. set: function (value) {
  4120. if (this._fontSize.toString(this._host) === value) {
  4121. return;
  4122. }
  4123. if (this._fontSize.fromString(value)) {
  4124. this._markAsDirty();
  4125. this._resetFontCache();
  4126. }
  4127. },
  4128. enumerable: true,
  4129. configurable: true
  4130. });
  4131. Object.defineProperty(Control.prototype, "color", {
  4132. /** Gets or sets foreground color */
  4133. get: function () {
  4134. return this._color;
  4135. },
  4136. set: function (value) {
  4137. if (this._color === value) {
  4138. return;
  4139. }
  4140. this._color = value;
  4141. this._markAsDirty();
  4142. },
  4143. enumerable: true,
  4144. configurable: true
  4145. });
  4146. Object.defineProperty(Control.prototype, "zIndex", {
  4147. /** Gets or sets z index which is used to reorder controls on the z axis */
  4148. get: function () {
  4149. return this._zIndex;
  4150. },
  4151. set: function (value) {
  4152. if (this.zIndex === value) {
  4153. return;
  4154. }
  4155. this._zIndex = value;
  4156. if (this.parent) {
  4157. this.parent._reOrderControl(this);
  4158. }
  4159. },
  4160. enumerable: true,
  4161. configurable: true
  4162. });
  4163. Object.defineProperty(Control.prototype, "notRenderable", {
  4164. /** Gets or sets a boolean indicating if the control can be rendered */
  4165. get: function () {
  4166. return this._doNotRender;
  4167. },
  4168. set: function (value) {
  4169. if (this._doNotRender === value) {
  4170. return;
  4171. }
  4172. this._doNotRender = value;
  4173. this._markAsDirty();
  4174. },
  4175. enumerable: true,
  4176. configurable: true
  4177. });
  4178. Object.defineProperty(Control.prototype, "isVisible", {
  4179. /** Gets or sets a boolean indicating if the control is visible */
  4180. get: function () {
  4181. return this._isVisible;
  4182. },
  4183. set: function (value) {
  4184. if (this._isVisible === value) {
  4185. return;
  4186. }
  4187. this._isVisible = value;
  4188. this._markAsDirty(true);
  4189. },
  4190. enumerable: true,
  4191. configurable: true
  4192. });
  4193. Object.defineProperty(Control.prototype, "isDirty", {
  4194. /** Gets a boolean indicating that the control needs to update its rendering */
  4195. get: function () {
  4196. return this._isDirty;
  4197. },
  4198. enumerable: true,
  4199. configurable: true
  4200. });
  4201. Object.defineProperty(Control.prototype, "linkedMesh", {
  4202. /**
  4203. * Gets the current linked mesh (or null if none)
  4204. */
  4205. get: function () {
  4206. return this._linkedMesh;
  4207. },
  4208. enumerable: true,
  4209. configurable: true
  4210. });
  4211. Object.defineProperty(Control.prototype, "paddingLeft", {
  4212. /**
  4213. * Gets or sets a value indicating the padding to use on the left of the control
  4214. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4215. */
  4216. get: function () {
  4217. return this._paddingLeft.toString(this._host);
  4218. },
  4219. set: function (value) {
  4220. if (this._paddingLeft.fromString(value)) {
  4221. this._markAsDirty();
  4222. }
  4223. },
  4224. enumerable: true,
  4225. configurable: true
  4226. });
  4227. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4228. /**
  4229. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4230. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4231. */
  4232. get: function () {
  4233. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4234. },
  4235. set: function (value) {
  4236. if (isNaN(value)) {
  4237. return;
  4238. }
  4239. this.paddingLeft = value + "px";
  4240. },
  4241. enumerable: true,
  4242. configurable: true
  4243. });
  4244. Object.defineProperty(Control.prototype, "paddingRight", {
  4245. /**
  4246. * Gets or sets a value indicating the padding to use on the right of the control
  4247. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4248. */
  4249. get: function () {
  4250. return this._paddingRight.toString(this._host);
  4251. },
  4252. set: function (value) {
  4253. if (this._paddingRight.fromString(value)) {
  4254. this._markAsDirty();
  4255. }
  4256. },
  4257. enumerable: true,
  4258. configurable: true
  4259. });
  4260. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4261. /**
  4262. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4263. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4264. */
  4265. get: function () {
  4266. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4267. },
  4268. set: function (value) {
  4269. if (isNaN(value)) {
  4270. return;
  4271. }
  4272. this.paddingRight = value + "px";
  4273. },
  4274. enumerable: true,
  4275. configurable: true
  4276. });
  4277. Object.defineProperty(Control.prototype, "paddingTop", {
  4278. /**
  4279. * Gets or sets a value indicating the padding to use on the top of the control
  4280. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4281. */
  4282. get: function () {
  4283. return this._paddingTop.toString(this._host);
  4284. },
  4285. set: function (value) {
  4286. if (this._paddingTop.fromString(value)) {
  4287. this._markAsDirty();
  4288. }
  4289. },
  4290. enumerable: true,
  4291. configurable: true
  4292. });
  4293. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4294. /**
  4295. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4296. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4297. */
  4298. get: function () {
  4299. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4300. },
  4301. set: function (value) {
  4302. if (isNaN(value)) {
  4303. return;
  4304. }
  4305. this.paddingTop = value + "px";
  4306. },
  4307. enumerable: true,
  4308. configurable: true
  4309. });
  4310. Object.defineProperty(Control.prototype, "paddingBottom", {
  4311. /**
  4312. * Gets or sets a value indicating the padding to use on the bottom of the control
  4313. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4314. */
  4315. get: function () {
  4316. return this._paddingBottom.toString(this._host);
  4317. },
  4318. set: function (value) {
  4319. if (this._paddingBottom.fromString(value)) {
  4320. this._markAsDirty();
  4321. }
  4322. },
  4323. enumerable: true,
  4324. configurable: true
  4325. });
  4326. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4327. /**
  4328. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4329. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4330. */
  4331. get: function () {
  4332. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4333. },
  4334. set: function (value) {
  4335. if (isNaN(value)) {
  4336. return;
  4337. }
  4338. this.paddingBottom = value + "px";
  4339. },
  4340. enumerable: true,
  4341. configurable: true
  4342. });
  4343. Object.defineProperty(Control.prototype, "left", {
  4344. /**
  4345. * Gets or sets a value indicating the left coordinate of the control
  4346. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4347. */
  4348. get: function () {
  4349. return this._left.toString(this._host);
  4350. },
  4351. set: function (value) {
  4352. if (this._left.fromString(value)) {
  4353. this._markAsDirty();
  4354. }
  4355. },
  4356. enumerable: true,
  4357. configurable: true
  4358. });
  4359. Object.defineProperty(Control.prototype, "leftInPixels", {
  4360. /**
  4361. * Gets or sets a value indicating the left coordinate in pixels of the control
  4362. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4363. */
  4364. get: function () {
  4365. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4366. },
  4367. set: function (value) {
  4368. if (isNaN(value)) {
  4369. return;
  4370. }
  4371. this.left = value + "px";
  4372. },
  4373. enumerable: true,
  4374. configurable: true
  4375. });
  4376. Object.defineProperty(Control.prototype, "top", {
  4377. /**
  4378. * Gets or sets a value indicating the top coordinate of the control
  4379. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4380. */
  4381. get: function () {
  4382. return this._top.toString(this._host);
  4383. },
  4384. set: function (value) {
  4385. if (this._top.fromString(value)) {
  4386. this._markAsDirty();
  4387. }
  4388. },
  4389. enumerable: true,
  4390. configurable: true
  4391. });
  4392. Object.defineProperty(Control.prototype, "topInPixels", {
  4393. /**
  4394. * Gets or sets a value indicating the top coordinate in pixels of the control
  4395. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4396. */
  4397. get: function () {
  4398. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4399. },
  4400. set: function (value) {
  4401. if (isNaN(value)) {
  4402. return;
  4403. }
  4404. this.top = value + "px";
  4405. },
  4406. enumerable: true,
  4407. configurable: true
  4408. });
  4409. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4410. /**
  4411. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4412. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4413. */
  4414. get: function () {
  4415. return this._linkOffsetX.toString(this._host);
  4416. },
  4417. set: function (value) {
  4418. if (this._linkOffsetX.fromString(value)) {
  4419. this._markAsDirty();
  4420. }
  4421. },
  4422. enumerable: true,
  4423. configurable: true
  4424. });
  4425. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4426. /**
  4427. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4428. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4429. */
  4430. get: function () {
  4431. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4432. },
  4433. set: function (value) {
  4434. if (isNaN(value)) {
  4435. return;
  4436. }
  4437. this.linkOffsetX = value + "px";
  4438. },
  4439. enumerable: true,
  4440. configurable: true
  4441. });
  4442. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4443. /**
  4444. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4445. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4446. */
  4447. get: function () {
  4448. return this._linkOffsetY.toString(this._host);
  4449. },
  4450. set: function (value) {
  4451. if (this._linkOffsetY.fromString(value)) {
  4452. this._markAsDirty();
  4453. }
  4454. },
  4455. enumerable: true,
  4456. configurable: true
  4457. });
  4458. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4459. /**
  4460. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4461. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4462. */
  4463. get: function () {
  4464. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4465. },
  4466. set: function (value) {
  4467. if (isNaN(value)) {
  4468. return;
  4469. }
  4470. this.linkOffsetY = value + "px";
  4471. },
  4472. enumerable: true,
  4473. configurable: true
  4474. });
  4475. Object.defineProperty(Control.prototype, "centerX", {
  4476. /** Gets the center coordinate on X axis */
  4477. get: function () {
  4478. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4479. },
  4480. enumerable: true,
  4481. configurable: true
  4482. });
  4483. Object.defineProperty(Control.prototype, "centerY", {
  4484. /** Gets the center coordinate on Y axis */
  4485. get: function () {
  4486. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4487. },
  4488. enumerable: true,
  4489. configurable: true
  4490. });
  4491. Object.defineProperty(Control.prototype, "isEnabled", {
  4492. /** Gets or sets if control is Enabled*/
  4493. get: function () {
  4494. return this._isEnabled;
  4495. },
  4496. set: function (value) {
  4497. if (this._isEnabled === value) {
  4498. return;
  4499. }
  4500. this._isEnabled = value;
  4501. this._markAsDirty();
  4502. },
  4503. enumerable: true,
  4504. configurable: true
  4505. });
  4506. Object.defineProperty(Control.prototype, "disabledColor", {
  4507. /** Gets or sets background color of control if it's disabled*/
  4508. get: function () {
  4509. return this._disabledColor;
  4510. },
  4511. set: function (value) {
  4512. if (this._disabledColor === value) {
  4513. return;
  4514. }
  4515. this._disabledColor = value;
  4516. this._markAsDirty();
  4517. },
  4518. enumerable: true,
  4519. configurable: true
  4520. });
  4521. /** @hidden */
  4522. Control.prototype._getTypeName = function () {
  4523. return "Control";
  4524. };
  4525. /**
  4526. * Gets the first ascendant in the hierarchy of the given type
  4527. * @param className defines the required type
  4528. * @returns the ascendant or null if not found
  4529. */
  4530. Control.prototype.getAscendantOfClass = function (className) {
  4531. if (!this.parent) {
  4532. return null;
  4533. }
  4534. if (this.parent.getClassName() === className) {
  4535. return this.parent;
  4536. }
  4537. return this.parent.getAscendantOfClass(className);
  4538. };
  4539. /** @hidden */
  4540. Control.prototype._resetFontCache = function () {
  4541. this._fontSet = true;
  4542. this._markAsDirty();
  4543. };
  4544. /**
  4545. * Determines if a container is an ascendant of the current control
  4546. * @param container defines the container to look for
  4547. * @returns true if the container is one of the ascendant of the control
  4548. */
  4549. Control.prototype.isAscendant = function (container) {
  4550. if (!this.parent) {
  4551. return false;
  4552. }
  4553. if (this.parent === container) {
  4554. return true;
  4555. }
  4556. return this.parent.isAscendant(container);
  4557. };
  4558. /**
  4559. * Gets coordinates in local control space
  4560. * @param globalCoordinates defines the coordinates to transform
  4561. * @returns the new coordinates in local space
  4562. */
  4563. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4564. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4565. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4566. return result;
  4567. };
  4568. /**
  4569. * Gets coordinates in local control space
  4570. * @param globalCoordinates defines the coordinates to transform
  4571. * @param result defines the target vector2 where to store the result
  4572. * @returns the current control
  4573. */
  4574. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4575. result.x = globalCoordinates.x - this._currentMeasure.left;
  4576. result.y = globalCoordinates.y - this._currentMeasure.top;
  4577. return this;
  4578. };
  4579. /**
  4580. * Gets coordinates in parent local control space
  4581. * @param globalCoordinates defines the coordinates to transform
  4582. * @returns the new coordinates in parent local space
  4583. */
  4584. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4585. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4586. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4587. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4588. return result;
  4589. };
  4590. /**
  4591. * Move the current control to a vector3 position projected onto the screen.
  4592. * @param position defines the target position
  4593. * @param scene defines the hosting scene
  4594. */
  4595. Control.prototype.moveToVector3 = function (position, scene) {
  4596. if (!this._host || this.parent !== this._host._rootContainer) {
  4597. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4598. return;
  4599. }
  4600. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4601. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4602. var globalViewport = this._host._getGlobalViewport(scene);
  4603. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4604. this._moveToProjectedPosition(projectedPosition);
  4605. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4606. this.notRenderable = true;
  4607. return;
  4608. }
  4609. this.notRenderable = false;
  4610. };
  4611. /** @hidden */
  4612. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4613. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4614. // Do nothing by default
  4615. };
  4616. /**
  4617. * Will return all controls that have this control as ascendant
  4618. * @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
  4619. * @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
  4620. * @return all child controls
  4621. */
  4622. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4623. var results = new Array();
  4624. this._getDescendants(results, directDescendantsOnly, predicate);
  4625. return results;
  4626. };
  4627. /**
  4628. * Link current control with a target mesh
  4629. * @param mesh defines the mesh to link with
  4630. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4631. */
  4632. Control.prototype.linkWithMesh = function (mesh) {
  4633. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4634. if (mesh) {
  4635. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4636. }
  4637. return;
  4638. }
  4639. var index = this._host._linkedControls.indexOf(this);
  4640. if (index !== -1) {
  4641. this._linkedMesh = mesh;
  4642. if (!mesh) {
  4643. this._host._linkedControls.splice(index, 1);
  4644. }
  4645. return;
  4646. }
  4647. else if (!mesh) {
  4648. return;
  4649. }
  4650. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4651. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4652. this._linkedMesh = mesh;
  4653. this._host._linkedControls.push(this);
  4654. };
  4655. /** @hidden */
  4656. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4657. var oldLeft = this._left.getValue(this._host);
  4658. var oldTop = this._top.getValue(this._host);
  4659. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4660. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4661. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4662. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4663. newLeft = oldLeft;
  4664. }
  4665. if (Math.abs(newTop - oldTop) < 0.5) {
  4666. newTop = oldTop;
  4667. }
  4668. }
  4669. this.left = newLeft + "px";
  4670. this.top = newTop + "px";
  4671. this._left.ignoreAdaptiveScaling = true;
  4672. this._top.ignoreAdaptiveScaling = true;
  4673. this._markAsDirty();
  4674. };
  4675. /** @hidden */
  4676. Control.prototype._offsetLeft = function (offset) {
  4677. this._isDirty = true;
  4678. this._currentMeasure.left += offset;
  4679. };
  4680. /** @hidden */
  4681. Control.prototype._offsetTop = function (offset) {
  4682. this._isDirty = true;
  4683. this._currentMeasure.top += offset;
  4684. };
  4685. /** @hidden */
  4686. Control.prototype._markMatrixAsDirty = function () {
  4687. this._isMatrixDirty = true;
  4688. this._flagDescendantsAsMatrixDirty();
  4689. };
  4690. /** @hidden */
  4691. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4692. // No child
  4693. };
  4694. /** @hidden */
  4695. Control.prototype._intersectsRect = function (rect) {
  4696. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4697. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4698. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4699. return false;
  4700. }
  4701. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4702. return false;
  4703. }
  4704. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4705. return false;
  4706. }
  4707. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4708. return false;
  4709. }
  4710. return true;
  4711. };
  4712. /** @hidden */
  4713. Control.prototype.invalidateRect = function () {
  4714. this._transform();
  4715. if (this.host && this.host.useInvalidateRectOptimization) {
  4716. // Rotate by transform to get the measure transformed to global space
  4717. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4718. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4719. // the previous measure is used to properly clear a control that is scaled down
  4720. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4721. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4722. // Expand rect based on shadows
  4723. var shadowOffsetX = this.shadowOffsetX;
  4724. var shadowOffsetY = this.shadowOffsetY;
  4725. var shadowBlur = this.shadowBlur;
  4726. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4727. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4728. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4729. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4730. 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));
  4731. }
  4732. else {
  4733. 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));
  4734. }
  4735. }
  4736. };
  4737. /** @hidden */
  4738. Control.prototype._markAsDirty = function (force) {
  4739. if (force === void 0) { force = false; }
  4740. if (!this._isVisible && !force) {
  4741. return;
  4742. }
  4743. this._isDirty = true;
  4744. // Redraw only this rectangle
  4745. if (this._host) {
  4746. this._host.markAsDirty();
  4747. }
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._markAllAsDirty = function () {
  4751. this._markAsDirty();
  4752. if (this._font) {
  4753. this._prepareFont();
  4754. }
  4755. };
  4756. /** @hidden */
  4757. Control.prototype._link = function (host) {
  4758. this._host = host;
  4759. if (this._host) {
  4760. this.uniqueId = this._host.getScene().getUniqueId();
  4761. }
  4762. };
  4763. /** @hidden */
  4764. Control.prototype._transform = function (context) {
  4765. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4766. return;
  4767. }
  4768. // postTranslate
  4769. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4770. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4771. if (context) {
  4772. context.translate(offsetX, offsetY);
  4773. // rotate
  4774. context.rotate(this._rotation);
  4775. // scale
  4776. context.scale(this._scaleX, this._scaleY);
  4777. // preTranslate
  4778. context.translate(-offsetX, -offsetY);
  4779. }
  4780. // Need to update matrices?
  4781. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4782. this._cachedOffsetX = offsetX;
  4783. this._cachedOffsetY = offsetY;
  4784. this._isMatrixDirty = false;
  4785. this._flagDescendantsAsMatrixDirty();
  4786. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4787. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4788. }
  4789. };
  4790. /** @hidden */
  4791. Control.prototype._renderHighlight = function (context) {
  4792. if (!this.isHighlighted) {
  4793. return;
  4794. }
  4795. context.save();
  4796. context.strokeStyle = "#4affff";
  4797. context.lineWidth = 2;
  4798. this._renderHighlightSpecific(context);
  4799. context.restore();
  4800. };
  4801. /** @hidden */
  4802. Control.prototype._renderHighlightSpecific = function (context) {
  4803. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4804. };
  4805. /** @hidden */
  4806. Control.prototype._applyStates = function (context) {
  4807. if (this._isFontSizeInPercentage) {
  4808. this._fontSet = true;
  4809. }
  4810. if (this._fontSet) {
  4811. this._prepareFont();
  4812. this._fontSet = false;
  4813. }
  4814. if (this._font) {
  4815. context.font = this._font;
  4816. }
  4817. if (this._color) {
  4818. context.fillStyle = this._color;
  4819. }
  4820. if (Control.AllowAlphaInheritance) {
  4821. context.globalAlpha *= this._alpha;
  4822. }
  4823. else if (this._alphaSet) {
  4824. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4825. }
  4826. };
  4827. /** @hidden */
  4828. Control.prototype._layout = function (parentMeasure, context) {
  4829. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4830. return false;
  4831. }
  4832. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4833. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4834. context.save();
  4835. this._applyStates(context);
  4836. var rebuildCount = 0;
  4837. do {
  4838. this._rebuildLayout = false;
  4839. this._processMeasures(parentMeasure, context);
  4840. rebuildCount++;
  4841. } while (this._rebuildLayout && rebuildCount < 3);
  4842. if (rebuildCount >= 3) {
  4843. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4844. }
  4845. context.restore();
  4846. this.invalidateRect();
  4847. this._evaluateClippingState(parentMeasure);
  4848. }
  4849. this._wasDirty = this._isDirty;
  4850. this._isDirty = false;
  4851. return true;
  4852. };
  4853. /** @hidden */
  4854. Control.prototype._processMeasures = function (parentMeasure, context) {
  4855. this._currentMeasure.copyFrom(parentMeasure);
  4856. // Let children take some pre-measurement actions
  4857. this._preMeasure(parentMeasure, context);
  4858. this._measure();
  4859. this._computeAlignment(parentMeasure, context);
  4860. // Convert to int values
  4861. this._currentMeasure.left = this._currentMeasure.left | 0;
  4862. this._currentMeasure.top = this._currentMeasure.top | 0;
  4863. this._currentMeasure.width = this._currentMeasure.width | 0;
  4864. this._currentMeasure.height = this._currentMeasure.height | 0;
  4865. // Let children add more features
  4866. this._additionalProcessing(parentMeasure, context);
  4867. this._cachedParentMeasure.copyFrom(parentMeasure);
  4868. if (this.onDirtyObservable.hasObservers()) {
  4869. this.onDirtyObservable.notifyObservers(this);
  4870. }
  4871. };
  4872. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4873. if (this.parent && this.parent.clipChildren) {
  4874. // Early clip
  4875. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4876. this._isClipped = true;
  4877. return;
  4878. }
  4879. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4880. this._isClipped = true;
  4881. return;
  4882. }
  4883. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4884. this._isClipped = true;
  4885. return;
  4886. }
  4887. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4888. this._isClipped = true;
  4889. return;
  4890. }
  4891. }
  4892. this._isClipped = false;
  4893. };
  4894. /** @hidden */
  4895. Control.prototype._measure = function () {
  4896. // Width / Height
  4897. if (this._width.isPixel) {
  4898. this._currentMeasure.width = this._width.getValue(this._host);
  4899. }
  4900. else {
  4901. this._currentMeasure.width *= this._width.getValue(this._host);
  4902. }
  4903. if (this._height.isPixel) {
  4904. this._currentMeasure.height = this._height.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.height *= this._height.getValue(this._host);
  4908. }
  4909. };
  4910. /** @hidden */
  4911. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4912. var width = this._currentMeasure.width;
  4913. var height = this._currentMeasure.height;
  4914. var parentWidth = parentMeasure.width;
  4915. var parentHeight = parentMeasure.height;
  4916. // Left / top
  4917. var x = 0;
  4918. var y = 0;
  4919. switch (this.horizontalAlignment) {
  4920. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4921. x = 0;
  4922. break;
  4923. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4924. x = parentWidth - width;
  4925. break;
  4926. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4927. x = (parentWidth - width) / 2;
  4928. break;
  4929. }
  4930. switch (this.verticalAlignment) {
  4931. case Control.VERTICAL_ALIGNMENT_TOP:
  4932. y = 0;
  4933. break;
  4934. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4935. y = parentHeight - height;
  4936. break;
  4937. case Control.VERTICAL_ALIGNMENT_CENTER:
  4938. y = (parentHeight - height) / 2;
  4939. break;
  4940. }
  4941. if (this._paddingLeft.isPixel) {
  4942. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4943. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4944. }
  4945. else {
  4946. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4947. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4948. }
  4949. if (this._paddingRight.isPixel) {
  4950. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4951. }
  4952. else {
  4953. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4954. }
  4955. if (this._paddingTop.isPixel) {
  4956. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4957. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4958. }
  4959. else {
  4960. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4961. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4962. }
  4963. if (this._paddingBottom.isPixel) {
  4964. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4965. }
  4966. else {
  4967. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4968. }
  4969. if (this._left.isPixel) {
  4970. this._currentMeasure.left += this._left.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4974. }
  4975. if (this._top.isPixel) {
  4976. this._currentMeasure.top += this._top.getValue(this._host);
  4977. }
  4978. else {
  4979. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4980. }
  4981. this._currentMeasure.left += x;
  4982. this._currentMeasure.top += y;
  4983. };
  4984. /** @hidden */
  4985. Control.prototype._preMeasure = function (parentMeasure, context) {
  4986. // Do nothing
  4987. };
  4988. /** @hidden */
  4989. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4990. // Do nothing
  4991. };
  4992. /** @hidden */
  4993. Control.prototype._clipForChildren = function (context) {
  4994. // DO nothing
  4995. };
  4996. Control.prototype._clip = function (context, invalidatedRectangle) {
  4997. context.beginPath();
  4998. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4999. if (invalidatedRectangle) {
  5000. // Rotate the invalidated rect into the control's space
  5001. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5002. // Get the intersection of the rect in context space and the current context
  5003. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5004. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5005. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5006. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5007. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5008. Control._ClipMeasure.copyFrom(intersection);
  5009. }
  5010. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5011. var shadowOffsetX = this.shadowOffsetX;
  5012. var shadowOffsetY = this.shadowOffsetY;
  5013. var shadowBlur = this.shadowBlur;
  5014. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5015. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5016. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5017. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5018. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5019. }
  5020. else {
  5021. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5022. }
  5023. context.clip();
  5024. };
  5025. /** @hidden */
  5026. Control.prototype._render = function (context, invalidatedRectangle) {
  5027. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5028. this._isDirty = false;
  5029. return false;
  5030. }
  5031. context.save();
  5032. this._applyStates(context);
  5033. // Transform
  5034. this._transform(context);
  5035. // Clip
  5036. if (this.clipContent) {
  5037. this._clip(context, invalidatedRectangle);
  5038. }
  5039. if (this.onBeforeDrawObservable.hasObservers()) {
  5040. this.onBeforeDrawObservable.notifyObservers(this);
  5041. }
  5042. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5043. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5044. }
  5045. else {
  5046. this._draw(context, invalidatedRectangle);
  5047. }
  5048. if (this.useBitmapCache && this._wasDirty) {
  5049. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5050. }
  5051. this._renderHighlight(context);
  5052. if (this.onAfterDrawObservable.hasObservers()) {
  5053. this.onAfterDrawObservable.notifyObservers(this);
  5054. }
  5055. context.restore();
  5056. return true;
  5057. };
  5058. /** @hidden */
  5059. Control.prototype._draw = function (context, invalidatedRectangle) {
  5060. // Do nothing
  5061. };
  5062. /**
  5063. * Tests if a given coordinates belong to the current control
  5064. * @param x defines x coordinate to test
  5065. * @param y defines y coordinate to test
  5066. * @returns true if the coordinates are inside the control
  5067. */
  5068. Control.prototype.contains = function (x, y) {
  5069. // Invert transform
  5070. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5071. x = this._transformedPosition.x;
  5072. y = this._transformedPosition.y;
  5073. // Check
  5074. if (x < this._currentMeasure.left) {
  5075. return false;
  5076. }
  5077. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5078. return false;
  5079. }
  5080. if (y < this._currentMeasure.top) {
  5081. return false;
  5082. }
  5083. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5084. return false;
  5085. }
  5086. if (this.isPointerBlocker) {
  5087. this._host._shouldBlockPointer = true;
  5088. }
  5089. return true;
  5090. };
  5091. /** @hidden */
  5092. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5093. if (!this._isEnabled) {
  5094. return false;
  5095. }
  5096. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5097. return false;
  5098. }
  5099. if (!this.contains(x, y)) {
  5100. return false;
  5101. }
  5102. this._processObservables(type, x, y, pointerId, buttonIndex);
  5103. return true;
  5104. };
  5105. /** @hidden */
  5106. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5107. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5108. if (canNotify && this.parent != null) {
  5109. this.parent._onPointerMove(target, coordinates, pointerId);
  5110. }
  5111. };
  5112. /** @hidden */
  5113. Control.prototype._onPointerEnter = function (target) {
  5114. if (!this._isEnabled) {
  5115. return false;
  5116. }
  5117. if (this._enterCount > 0) {
  5118. return false;
  5119. }
  5120. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5121. this._enterCount = 0;
  5122. }
  5123. this._enterCount++;
  5124. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5125. if (canNotify && this.parent != null) {
  5126. this.parent._onPointerEnter(target);
  5127. }
  5128. return true;
  5129. };
  5130. /** @hidden */
  5131. Control.prototype._onPointerOut = function (target, force) {
  5132. if (force === void 0) { force = false; }
  5133. if (!force && (!this._isEnabled || target === this)) {
  5134. return;
  5135. }
  5136. this._enterCount = 0;
  5137. var canNotify = true;
  5138. if (!target.isAscendant(this)) {
  5139. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5140. }
  5141. if (canNotify && this.parent != null) {
  5142. this.parent._onPointerOut(target, force);
  5143. }
  5144. };
  5145. /** @hidden */
  5146. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5147. // Prevent pointerout to lose control context.
  5148. // Event redundancy is checked inside the function.
  5149. this._onPointerEnter(this);
  5150. if (this._downCount !== 0) {
  5151. return false;
  5152. }
  5153. this._downCount++;
  5154. this._downPointerIds[pointerId] = true;
  5155. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5156. if (canNotify && this.parent != null) {
  5157. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5158. }
  5159. return true;
  5160. };
  5161. /** @hidden */
  5162. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5163. if (!this._isEnabled) {
  5164. return;
  5165. }
  5166. this._downCount = 0;
  5167. delete this._downPointerIds[pointerId];
  5168. var canNotifyClick = notifyClick;
  5169. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5170. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5171. }
  5172. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5173. if (canNotify && this.parent != null) {
  5174. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5175. }
  5176. };
  5177. /** @hidden */
  5178. Control.prototype._forcePointerUp = function (pointerId) {
  5179. if (pointerId === void 0) { pointerId = null; }
  5180. if (pointerId !== null) {
  5181. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5182. }
  5183. else {
  5184. for (var key in this._downPointerIds) {
  5185. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5186. }
  5187. }
  5188. };
  5189. /** @hidden */
  5190. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5191. if (!this._isEnabled) {
  5192. return false;
  5193. }
  5194. this._dummyVector2.copyFromFloats(x, y);
  5195. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5196. this._onPointerMove(this, this._dummyVector2, pointerId);
  5197. var previousControlOver = this._host._lastControlOver[pointerId];
  5198. if (previousControlOver && previousControlOver !== this) {
  5199. previousControlOver._onPointerOut(this);
  5200. }
  5201. if (previousControlOver !== this) {
  5202. this._onPointerEnter(this);
  5203. }
  5204. this._host._lastControlOver[pointerId] = this;
  5205. return true;
  5206. }
  5207. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5208. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5209. this._host._registerLastControlDown(this, pointerId);
  5210. this._host._lastPickedControl = this;
  5211. return true;
  5212. }
  5213. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5214. if (this._host._lastControlDown[pointerId]) {
  5215. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5216. }
  5217. delete this._host._lastControlDown[pointerId];
  5218. return true;
  5219. }
  5220. return false;
  5221. };
  5222. Control.prototype._prepareFont = function () {
  5223. if (!this._font && !this._fontSet) {
  5224. return;
  5225. }
  5226. if (this._style) {
  5227. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5228. }
  5229. else {
  5230. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5231. }
  5232. this._fontOffset = Control._GetFontOffset(this._font);
  5233. };
  5234. /** Releases associated resources */
  5235. Control.prototype.dispose = function () {
  5236. this.onDirtyObservable.clear();
  5237. this.onBeforeDrawObservable.clear();
  5238. this.onAfterDrawObservable.clear();
  5239. this.onPointerDownObservable.clear();
  5240. this.onPointerEnterObservable.clear();
  5241. this.onPointerMoveObservable.clear();
  5242. this.onPointerOutObservable.clear();
  5243. this.onPointerUpObservable.clear();
  5244. this.onPointerClickObservable.clear();
  5245. if (this._styleObserver && this._style) {
  5246. this._style.onChangedObservable.remove(this._styleObserver);
  5247. this._styleObserver = null;
  5248. }
  5249. if (this.parent) {
  5250. this.parent.removeControl(this);
  5251. this.parent = null;
  5252. }
  5253. if (this._host) {
  5254. var index = this._host._linkedControls.indexOf(this);
  5255. if (index > -1) {
  5256. this.linkWithMesh(null);
  5257. }
  5258. }
  5259. };
  5260. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5261. /** HORIZONTAL_ALIGNMENT_LEFT */
  5262. get: function () {
  5263. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5264. },
  5265. enumerable: true,
  5266. configurable: true
  5267. });
  5268. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5269. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5270. get: function () {
  5271. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5272. },
  5273. enumerable: true,
  5274. configurable: true
  5275. });
  5276. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5277. /** HORIZONTAL_ALIGNMENT_CENTER */
  5278. get: function () {
  5279. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5280. },
  5281. enumerable: true,
  5282. configurable: true
  5283. });
  5284. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5285. /** VERTICAL_ALIGNMENT_TOP */
  5286. get: function () {
  5287. return Control._VERTICAL_ALIGNMENT_TOP;
  5288. },
  5289. enumerable: true,
  5290. configurable: true
  5291. });
  5292. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5293. /** VERTICAL_ALIGNMENT_BOTTOM */
  5294. get: function () {
  5295. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5296. },
  5297. enumerable: true,
  5298. configurable: true
  5299. });
  5300. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5301. /** VERTICAL_ALIGNMENT_CENTER */
  5302. get: function () {
  5303. return Control._VERTICAL_ALIGNMENT_CENTER;
  5304. },
  5305. enumerable: true,
  5306. configurable: true
  5307. });
  5308. /** @hidden */
  5309. Control._GetFontOffset = function (font) {
  5310. if (Control._FontHeightSizes[font]) {
  5311. return Control._FontHeightSizes[font];
  5312. }
  5313. var text = document.createElement("span");
  5314. text.innerHTML = "Hg";
  5315. text.style.font = font;
  5316. var block = document.createElement("div");
  5317. block.style.display = "inline-block";
  5318. block.style.width = "1px";
  5319. block.style.height = "0px";
  5320. block.style.verticalAlign = "bottom";
  5321. var div = document.createElement("div");
  5322. div.appendChild(text);
  5323. div.appendChild(block);
  5324. document.body.appendChild(div);
  5325. var fontAscent = 0;
  5326. var fontHeight = 0;
  5327. try {
  5328. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5329. block.style.verticalAlign = "baseline";
  5330. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5331. }
  5332. finally {
  5333. document.body.removeChild(div);
  5334. }
  5335. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5336. Control._FontHeightSizes[font] = result;
  5337. return result;
  5338. };
  5339. /** @hidden */
  5340. Control.drawEllipse = function (x, y, width, height, context) {
  5341. context.translate(x, y);
  5342. context.scale(width, height);
  5343. context.beginPath();
  5344. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5345. context.closePath();
  5346. context.scale(1 / width, 1 / height);
  5347. context.translate(-x, -y);
  5348. };
  5349. /**
  5350. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5351. */
  5352. Control.AllowAlphaInheritance = false;
  5353. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5354. // Statics
  5355. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5356. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5357. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5358. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5359. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5360. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5361. Control._FontHeightSizes = {};
  5362. /**
  5363. * Creates a stack panel that can be used to render headers
  5364. * @param control defines the control to associate with the header
  5365. * @param text defines the text of the header
  5366. * @param size defines the size of the header
  5367. * @param options defines options used to configure the header
  5368. * @returns a new StackPanel
  5369. * @ignore
  5370. * @hidden
  5371. */
  5372. Control.AddHeader = function () { };
  5373. return Control;
  5374. }());
  5375. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5376. /***/ }),
  5377. /***/ "./2D/controls/displayGrid.ts":
  5378. /*!************************************!*\
  5379. !*** ./2D/controls/displayGrid.ts ***!
  5380. \************************************/
  5381. /*! exports provided: DisplayGrid */
  5382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5383. "use strict";
  5384. __webpack_require__.r(__webpack_exports__);
  5385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5386. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5387. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5388. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5389. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5390. /** Class used to render a grid */
  5391. var DisplayGrid = /** @class */ (function (_super) {
  5392. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5393. /**
  5394. * Creates a new GridDisplayRectangle
  5395. * @param name defines the control name
  5396. */
  5397. function DisplayGrid(name) {
  5398. var _this = _super.call(this, name) || this;
  5399. _this.name = name;
  5400. _this._cellWidth = 20;
  5401. _this._cellHeight = 20;
  5402. _this._minorLineTickness = 1;
  5403. _this._minorLineColor = "DarkGray";
  5404. _this._majorLineTickness = 2;
  5405. _this._majorLineColor = "White";
  5406. _this._majorLineFrequency = 5;
  5407. _this._background = "Black";
  5408. _this._displayMajorLines = true;
  5409. _this._displayMinorLines = true;
  5410. return _this;
  5411. }
  5412. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5413. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5414. get: function () {
  5415. return this._displayMinorLines;
  5416. },
  5417. set: function (value) {
  5418. if (this._displayMinorLines === value) {
  5419. return;
  5420. }
  5421. this._displayMinorLines = value;
  5422. this._markAsDirty();
  5423. },
  5424. enumerable: true,
  5425. configurable: true
  5426. });
  5427. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5428. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5429. get: function () {
  5430. return this._displayMajorLines;
  5431. },
  5432. set: function (value) {
  5433. if (this._displayMajorLines === value) {
  5434. return;
  5435. }
  5436. this._displayMajorLines = value;
  5437. this._markAsDirty();
  5438. },
  5439. enumerable: true,
  5440. configurable: true
  5441. });
  5442. Object.defineProperty(DisplayGrid.prototype, "background", {
  5443. /** Gets or sets background color (Black by default) */
  5444. get: function () {
  5445. return this._background;
  5446. },
  5447. set: function (value) {
  5448. if (this._background === value) {
  5449. return;
  5450. }
  5451. this._background = value;
  5452. this._markAsDirty();
  5453. },
  5454. enumerable: true,
  5455. configurable: true
  5456. });
  5457. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5458. /** Gets or sets the width of each cell (20 by default) */
  5459. get: function () {
  5460. return this._cellWidth;
  5461. },
  5462. set: function (value) {
  5463. this._cellWidth = value;
  5464. this._markAsDirty();
  5465. },
  5466. enumerable: true,
  5467. configurable: true
  5468. });
  5469. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5470. /** Gets or sets the height of each cell (20 by default) */
  5471. get: function () {
  5472. return this._cellHeight;
  5473. },
  5474. set: function (value) {
  5475. this._cellHeight = value;
  5476. this._markAsDirty();
  5477. },
  5478. enumerable: true,
  5479. configurable: true
  5480. });
  5481. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5482. /** Gets or sets the tickness of minor lines (1 by default) */
  5483. get: function () {
  5484. return this._minorLineTickness;
  5485. },
  5486. set: function (value) {
  5487. this._minorLineTickness = value;
  5488. this._markAsDirty();
  5489. },
  5490. enumerable: true,
  5491. configurable: true
  5492. });
  5493. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5494. /** Gets or sets the color of minor lines (DarkGray by default) */
  5495. get: function () {
  5496. return this._minorLineColor;
  5497. },
  5498. set: function (value) {
  5499. this._minorLineColor = value;
  5500. this._markAsDirty();
  5501. },
  5502. enumerable: true,
  5503. configurable: true
  5504. });
  5505. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5506. /** Gets or sets the tickness of major lines (2 by default) */
  5507. get: function () {
  5508. return this._majorLineTickness;
  5509. },
  5510. set: function (value) {
  5511. this._majorLineTickness = value;
  5512. this._markAsDirty();
  5513. },
  5514. enumerable: true,
  5515. configurable: true
  5516. });
  5517. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5518. /** Gets or sets the color of major lines (White by default) */
  5519. get: function () {
  5520. return this._majorLineColor;
  5521. },
  5522. set: function (value) {
  5523. this._majorLineColor = value;
  5524. this._markAsDirty();
  5525. },
  5526. enumerable: true,
  5527. configurable: true
  5528. });
  5529. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5530. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5531. get: function () {
  5532. return this._majorLineFrequency;
  5533. },
  5534. set: function (value) {
  5535. this._majorLineFrequency = value;
  5536. this._markAsDirty();
  5537. },
  5538. enumerable: true,
  5539. configurable: true
  5540. });
  5541. DisplayGrid.prototype._draw = function (context) {
  5542. context.save();
  5543. this._applyStates(context);
  5544. if (this._isEnabled) {
  5545. if (this._background) {
  5546. context.fillStyle = this._background;
  5547. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5548. }
  5549. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5550. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5551. // Minor lines
  5552. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5553. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5554. if (this._displayMinorLines) {
  5555. context.strokeStyle = this._minorLineColor;
  5556. context.lineWidth = this._minorLineTickness;
  5557. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5558. var cellX = left + x * this.cellWidth;
  5559. context.beginPath();
  5560. context.moveTo(cellX, this._currentMeasure.top);
  5561. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5562. context.stroke();
  5563. }
  5564. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5565. var cellY = top_1 + y * this.cellHeight;
  5566. context.beginPath();
  5567. context.moveTo(this._currentMeasure.left, cellY);
  5568. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5569. context.stroke();
  5570. }
  5571. }
  5572. // Major lines
  5573. if (this._displayMajorLines) {
  5574. context.strokeStyle = this._majorLineColor;
  5575. context.lineWidth = this._majorLineTickness;
  5576. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5577. var cellX = left + x * this.cellWidth;
  5578. context.beginPath();
  5579. context.moveTo(cellX, this._currentMeasure.top);
  5580. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5581. context.stroke();
  5582. }
  5583. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5584. var cellY = top_1 + y * this.cellHeight;
  5585. context.moveTo(this._currentMeasure.left, cellY);
  5586. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5587. context.closePath();
  5588. context.stroke();
  5589. }
  5590. }
  5591. }
  5592. context.restore();
  5593. };
  5594. DisplayGrid.prototype._getTypeName = function () {
  5595. return "DisplayGrid";
  5596. };
  5597. return DisplayGrid;
  5598. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5599. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5600. /***/ }),
  5601. /***/ "./2D/controls/ellipse.ts":
  5602. /*!********************************!*\
  5603. !*** ./2D/controls/ellipse.ts ***!
  5604. \********************************/
  5605. /*! exports provided: Ellipse */
  5606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5607. "use strict";
  5608. __webpack_require__.r(__webpack_exports__);
  5609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5610. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5611. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5612. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5613. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5614. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5615. /** Class used to create 2D ellipse containers */
  5616. var Ellipse = /** @class */ (function (_super) {
  5617. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5618. /**
  5619. * Creates a new Ellipse
  5620. * @param name defines the control name
  5621. */
  5622. function Ellipse(name) {
  5623. var _this = _super.call(this, name) || this;
  5624. _this.name = name;
  5625. _this._thickness = 1;
  5626. return _this;
  5627. }
  5628. Object.defineProperty(Ellipse.prototype, "thickness", {
  5629. /** Gets or sets border thickness */
  5630. get: function () {
  5631. return this._thickness;
  5632. },
  5633. set: function (value) {
  5634. if (this._thickness === value) {
  5635. return;
  5636. }
  5637. this._thickness = value;
  5638. this._markAsDirty();
  5639. },
  5640. enumerable: true,
  5641. configurable: true
  5642. });
  5643. Ellipse.prototype._getTypeName = function () {
  5644. return "Ellipse";
  5645. };
  5646. Ellipse.prototype._localDraw = function (context) {
  5647. context.save();
  5648. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5649. context.shadowColor = this.shadowColor;
  5650. context.shadowBlur = this.shadowBlur;
  5651. context.shadowOffsetX = this.shadowOffsetX;
  5652. context.shadowOffsetY = this.shadowOffsetY;
  5653. }
  5654. _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);
  5655. if (this._background) {
  5656. context.fillStyle = this._background;
  5657. context.fill();
  5658. }
  5659. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5660. context.shadowBlur = 0;
  5661. context.shadowOffsetX = 0;
  5662. context.shadowOffsetY = 0;
  5663. }
  5664. if (this._thickness) {
  5665. if (this.color) {
  5666. context.strokeStyle = this.color;
  5667. }
  5668. context.lineWidth = this._thickness;
  5669. context.stroke();
  5670. }
  5671. context.restore();
  5672. };
  5673. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5674. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5675. this._measureForChildren.width -= 2 * this._thickness;
  5676. this._measureForChildren.height -= 2 * this._thickness;
  5677. this._measureForChildren.left += this._thickness;
  5678. this._measureForChildren.top += this._thickness;
  5679. };
  5680. Ellipse.prototype._clipForChildren = function (context) {
  5681. _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);
  5682. context.clip();
  5683. };
  5684. return Ellipse;
  5685. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5686. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5687. /***/ }),
  5688. /***/ "./2D/controls/grid.ts":
  5689. /*!*****************************!*\
  5690. !*** ./2D/controls/grid.ts ***!
  5691. \*****************************/
  5692. /*! exports provided: Grid */
  5693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5694. "use strict";
  5695. __webpack_require__.r(__webpack_exports__);
  5696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5698. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5699. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5700. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5701. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5702. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5703. /**
  5704. * Class used to create a 2D grid container
  5705. */
  5706. var Grid = /** @class */ (function (_super) {
  5707. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5708. /**
  5709. * Creates a new Grid
  5710. * @param name defines control name
  5711. */
  5712. function Grid(name) {
  5713. var _this = _super.call(this, name) || this;
  5714. _this.name = name;
  5715. _this._rowDefinitions = new Array();
  5716. _this._columnDefinitions = new Array();
  5717. _this._cells = {};
  5718. _this._childControls = new Array();
  5719. return _this;
  5720. }
  5721. Object.defineProperty(Grid.prototype, "columnCount", {
  5722. /**
  5723. * Gets the number of columns
  5724. */
  5725. get: function () {
  5726. return this._columnDefinitions.length;
  5727. },
  5728. enumerable: true,
  5729. configurable: true
  5730. });
  5731. Object.defineProperty(Grid.prototype, "rowCount", {
  5732. /**
  5733. * Gets the number of rows
  5734. */
  5735. get: function () {
  5736. return this._rowDefinitions.length;
  5737. },
  5738. enumerable: true,
  5739. configurable: true
  5740. });
  5741. Object.defineProperty(Grid.prototype, "children", {
  5742. /** Gets the list of children */
  5743. get: function () {
  5744. return this._childControls;
  5745. },
  5746. enumerable: true,
  5747. configurable: true
  5748. });
  5749. Object.defineProperty(Grid.prototype, "cells", {
  5750. /** Gets the list of cells (e.g. the containers) */
  5751. get: function () {
  5752. return this._cells;
  5753. },
  5754. enumerable: true,
  5755. configurable: true
  5756. });
  5757. /**
  5758. * Gets the definition of a specific row
  5759. * @param index defines the index of the row
  5760. * @returns the row definition
  5761. */
  5762. Grid.prototype.getRowDefinition = function (index) {
  5763. if (index < 0 || index >= this._rowDefinitions.length) {
  5764. return null;
  5765. }
  5766. return this._rowDefinitions[index];
  5767. };
  5768. /**
  5769. * Gets the definition of a specific column
  5770. * @param index defines the index of the column
  5771. * @returns the column definition
  5772. */
  5773. Grid.prototype.getColumnDefinition = function (index) {
  5774. if (index < 0 || index >= this._columnDefinitions.length) {
  5775. return null;
  5776. }
  5777. return this._columnDefinitions[index];
  5778. };
  5779. /**
  5780. * Adds a new row to the grid
  5781. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5782. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5783. * @returns the current grid
  5784. */
  5785. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5786. if (isPixel === void 0) { isPixel = false; }
  5787. 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));
  5788. this._markAsDirty();
  5789. return this;
  5790. };
  5791. /**
  5792. * Adds a new column to the grid
  5793. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5794. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5795. * @returns the current grid
  5796. */
  5797. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5798. if (isPixel === void 0) { isPixel = false; }
  5799. 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));
  5800. this._markAsDirty();
  5801. return this;
  5802. };
  5803. /**
  5804. * Update a row definition
  5805. * @param index defines the index of the row to update
  5806. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5807. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5808. * @returns the current grid
  5809. */
  5810. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5811. if (isPixel === void 0) { isPixel = false; }
  5812. if (index < 0 || index >= this._rowDefinitions.length) {
  5813. return this;
  5814. }
  5815. var current = this._rowDefinitions[index];
  5816. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5817. return this;
  5818. }
  5819. 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);
  5820. this._markAsDirty();
  5821. return this;
  5822. };
  5823. /**
  5824. * Update a column definition
  5825. * @param index defines the index of the column to update
  5826. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5827. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5828. * @returns the current grid
  5829. */
  5830. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5831. if (isPixel === void 0) { isPixel = false; }
  5832. if (index < 0 || index >= this._columnDefinitions.length) {
  5833. return this;
  5834. }
  5835. var current = this._columnDefinitions[index];
  5836. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5837. return this;
  5838. }
  5839. 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);
  5840. this._markAsDirty();
  5841. return this;
  5842. };
  5843. /**
  5844. * Gets the list of children stored in a specific cell
  5845. * @param row defines the row to check
  5846. * @param column defines the column to check
  5847. * @returns the list of controls
  5848. */
  5849. Grid.prototype.getChildrenAt = function (row, column) {
  5850. var cell = this._cells[row + ":" + column];
  5851. if (!cell) {
  5852. return null;
  5853. }
  5854. return cell.children;
  5855. };
  5856. /**
  5857. * Gets a string representing the child cell info (row x column)
  5858. * @param child defines the control to get info from
  5859. * @returns a string containing the child cell info (row x column)
  5860. */
  5861. Grid.prototype.getChildCellInfo = function (child) {
  5862. return child._tag;
  5863. };
  5864. Grid.prototype._removeCell = function (cell, key) {
  5865. if (!cell) {
  5866. return;
  5867. }
  5868. _super.prototype.removeControl.call(this, cell);
  5869. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5870. var control = _a[_i];
  5871. var childIndex = this._childControls.indexOf(control);
  5872. if (childIndex !== -1) {
  5873. this._childControls.splice(childIndex, 1);
  5874. }
  5875. }
  5876. delete this._cells[key];
  5877. };
  5878. Grid.prototype._offsetCell = function (previousKey, key) {
  5879. if (!this._cells[key]) {
  5880. return;
  5881. }
  5882. this._cells[previousKey] = this._cells[key];
  5883. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5884. var control = _a[_i];
  5885. control._tag = previousKey;
  5886. }
  5887. delete this._cells[key];
  5888. };
  5889. /**
  5890. * Remove a column definition at specified index
  5891. * @param index defines the index of the column to remove
  5892. * @returns the current grid
  5893. */
  5894. Grid.prototype.removeColumnDefinition = function (index) {
  5895. if (index < 0 || index >= this._columnDefinitions.length) {
  5896. return this;
  5897. }
  5898. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5899. var key = x + ":" + index;
  5900. var cell = this._cells[key];
  5901. this._removeCell(cell, key);
  5902. }
  5903. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5904. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5905. var previousKey = x + ":" + (y - 1);
  5906. var key = x + ":" + y;
  5907. this._offsetCell(previousKey, key);
  5908. }
  5909. }
  5910. this._columnDefinitions.splice(index, 1);
  5911. this._markAsDirty();
  5912. return this;
  5913. };
  5914. /**
  5915. * Remove a row definition at specified index
  5916. * @param index defines the index of the row to remove
  5917. * @returns the current grid
  5918. */
  5919. Grid.prototype.removeRowDefinition = function (index) {
  5920. if (index < 0 || index >= this._rowDefinitions.length) {
  5921. return this;
  5922. }
  5923. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5924. var key = index + ":" + y;
  5925. var cell = this._cells[key];
  5926. this._removeCell(cell, key);
  5927. }
  5928. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5929. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5930. var previousKey = x - 1 + ":" + y;
  5931. var key = x + ":" + y;
  5932. this._offsetCell(previousKey, key);
  5933. }
  5934. }
  5935. this._rowDefinitions.splice(index, 1);
  5936. this._markAsDirty();
  5937. return this;
  5938. };
  5939. /**
  5940. * Adds a new control to the current grid
  5941. * @param control defines the control to add
  5942. * @param row defines the row where to add the control (0 by default)
  5943. * @param column defines the column where to add the control (0 by default)
  5944. * @returns the current grid
  5945. */
  5946. Grid.prototype.addControl = function (control, row, column) {
  5947. if (row === void 0) { row = 0; }
  5948. if (column === void 0) { column = 0; }
  5949. if (this._rowDefinitions.length === 0) {
  5950. // Add default row definition
  5951. this.addRowDefinition(1, false);
  5952. }
  5953. if (this._columnDefinitions.length === 0) {
  5954. // Add default column definition
  5955. this.addColumnDefinition(1, false);
  5956. }
  5957. if (this._childControls.indexOf(control) !== -1) {
  5958. 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");
  5959. return this;
  5960. }
  5961. var x = Math.min(row, this._rowDefinitions.length - 1);
  5962. var y = Math.min(column, this._columnDefinitions.length - 1);
  5963. var key = x + ":" + y;
  5964. var goodContainer = this._cells[key];
  5965. if (!goodContainer) {
  5966. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5967. this._cells[key] = goodContainer;
  5968. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5969. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5970. _super.prototype.addControl.call(this, goodContainer);
  5971. }
  5972. goodContainer.addControl(control);
  5973. this._childControls.push(control);
  5974. control._tag = key;
  5975. control.parent = this;
  5976. this._markAsDirty();
  5977. return this;
  5978. };
  5979. /**
  5980. * Removes a control from the current container
  5981. * @param control defines the control to remove
  5982. * @returns the current container
  5983. */
  5984. Grid.prototype.removeControl = function (control) {
  5985. var index = this._childControls.indexOf(control);
  5986. if (index !== -1) {
  5987. this._childControls.splice(index, 1);
  5988. }
  5989. var cell = this._cells[control._tag];
  5990. if (cell) {
  5991. cell.removeControl(control);
  5992. control._tag = null;
  5993. }
  5994. this._markAsDirty();
  5995. return this;
  5996. };
  5997. Grid.prototype._getTypeName = function () {
  5998. return "Grid";
  5999. };
  6000. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6001. var widths = [];
  6002. var heights = [];
  6003. var lefts = [];
  6004. var tops = [];
  6005. var availableWidth = this._currentMeasure.width;
  6006. var globalWidthPercentage = 0;
  6007. var availableHeight = this._currentMeasure.height;
  6008. var globalHeightPercentage = 0;
  6009. // Heights
  6010. var index = 0;
  6011. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6012. var value = _a[_i];
  6013. if (value.isPixel) {
  6014. var height = value.getValue(this._host);
  6015. availableHeight -= height;
  6016. heights[index] = height;
  6017. }
  6018. else {
  6019. globalHeightPercentage += value.internalValue;
  6020. }
  6021. index++;
  6022. }
  6023. var top = 0;
  6024. index = 0;
  6025. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6026. var value = _c[_b];
  6027. tops.push(top);
  6028. if (!value.isPixel) {
  6029. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6030. top += height;
  6031. heights[index] = height;
  6032. }
  6033. else {
  6034. top += value.getValue(this._host);
  6035. }
  6036. index++;
  6037. }
  6038. // Widths
  6039. index = 0;
  6040. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6041. var value = _e[_d];
  6042. if (value.isPixel) {
  6043. var width = value.getValue(this._host);
  6044. availableWidth -= width;
  6045. widths[index] = width;
  6046. }
  6047. else {
  6048. globalWidthPercentage += value.internalValue;
  6049. }
  6050. index++;
  6051. }
  6052. var left = 0;
  6053. index = 0;
  6054. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6055. var value = _g[_f];
  6056. lefts.push(left);
  6057. if (!value.isPixel) {
  6058. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6059. left += width;
  6060. widths[index] = width;
  6061. }
  6062. else {
  6063. left += value.getValue(this._host);
  6064. }
  6065. index++;
  6066. }
  6067. definitionCallback(lefts, tops, widths, heights);
  6068. };
  6069. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6070. var _this = this;
  6071. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6072. // Setting child sizes
  6073. for (var key in _this._cells) {
  6074. if (!_this._cells.hasOwnProperty(key)) {
  6075. continue;
  6076. }
  6077. var split = key.split(":");
  6078. var x = parseInt(split[0]);
  6079. var y = parseInt(split[1]);
  6080. var cell = _this._cells[key];
  6081. cell.left = lefts[y] + "px";
  6082. cell.top = tops[x] + "px";
  6083. cell.width = widths[y] + "px";
  6084. cell.height = heights[x] + "px";
  6085. cell._left.ignoreAdaptiveScaling = true;
  6086. cell._top.ignoreAdaptiveScaling = true;
  6087. cell._width.ignoreAdaptiveScaling = true;
  6088. cell._height.ignoreAdaptiveScaling = true;
  6089. }
  6090. });
  6091. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6092. };
  6093. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6094. for (var key in this._cells) {
  6095. if (!this._cells.hasOwnProperty(key)) {
  6096. continue;
  6097. }
  6098. var child = this._cells[key];
  6099. child._markMatrixAsDirty();
  6100. }
  6101. };
  6102. Grid.prototype._renderHighlightSpecific = function (context) {
  6103. var _this = this;
  6104. _super.prototype._renderHighlightSpecific.call(this, context);
  6105. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6106. // Columns
  6107. for (var index = 0; index < lefts.length; index++) {
  6108. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6109. context.beginPath();
  6110. context.moveTo(left, _this._currentMeasure.top);
  6111. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6112. context.stroke();
  6113. }
  6114. // Rows
  6115. for (var index = 0; index < tops.length; index++) {
  6116. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6117. context.beginPath();
  6118. context.moveTo(_this._currentMeasure.left, top_1);
  6119. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6120. context.stroke();
  6121. }
  6122. });
  6123. context.restore();
  6124. };
  6125. /** Releases associated resources */
  6126. Grid.prototype.dispose = function () {
  6127. _super.prototype.dispose.call(this);
  6128. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6129. var control = _a[_i];
  6130. control.dispose();
  6131. }
  6132. this._childControls = [];
  6133. };
  6134. return Grid;
  6135. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6136. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6137. /***/ }),
  6138. /***/ "./2D/controls/image.ts":
  6139. /*!******************************!*\
  6140. !*** ./2D/controls/image.ts ***!
  6141. \******************************/
  6142. /*! exports provided: Image */
  6143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6144. "use strict";
  6145. __webpack_require__.r(__webpack_exports__);
  6146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6148. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6149. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6150. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6151. /**
  6152. * Class used to create 2D images
  6153. */
  6154. var Image = /** @class */ (function (_super) {
  6155. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6156. /**
  6157. * Creates a new Image
  6158. * @param name defines the control name
  6159. * @param url defines the image url
  6160. */
  6161. function Image(name, url) {
  6162. if (url === void 0) { url = null; }
  6163. var _this = _super.call(this, name) || this;
  6164. _this.name = name;
  6165. _this._loaded = false;
  6166. _this._stretch = Image.STRETCH_FILL;
  6167. _this._autoScale = false;
  6168. _this._sourceLeft = 0;
  6169. _this._sourceTop = 0;
  6170. _this._sourceWidth = 0;
  6171. _this._sourceHeight = 0;
  6172. _this._cellWidth = 0;
  6173. _this._cellHeight = 0;
  6174. _this._cellId = -1;
  6175. _this._populateNinePatchSlicesFromImage = false;
  6176. /**
  6177. * Observable notified when the content is loaded
  6178. */
  6179. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6180. /**
  6181. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6182. */
  6183. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6184. _this.source = url;
  6185. return _this;
  6186. }
  6187. Object.defineProperty(Image.prototype, "isLoaded", {
  6188. /**
  6189. * Gets a boolean indicating that the content is loaded
  6190. */
  6191. get: function () {
  6192. return this._loaded;
  6193. },
  6194. enumerable: true,
  6195. configurable: true
  6196. });
  6197. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6198. /**
  6199. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6200. */
  6201. get: function () {
  6202. return this._populateNinePatchSlicesFromImage;
  6203. },
  6204. set: function (value) {
  6205. if (this._populateNinePatchSlicesFromImage === value) {
  6206. return;
  6207. }
  6208. this._populateNinePatchSlicesFromImage = value;
  6209. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6210. this._extractNinePatchSliceDataFromImage();
  6211. }
  6212. },
  6213. enumerable: true,
  6214. configurable: true
  6215. });
  6216. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6217. /**
  6218. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6219. * Beware using this as this will comsume more memory as the image has to be stored twice
  6220. */
  6221. get: function () {
  6222. return this._detectPointerOnOpaqueOnly;
  6223. },
  6224. set: function (value) {
  6225. if (this._detectPointerOnOpaqueOnly === value) {
  6226. return;
  6227. }
  6228. this._detectPointerOnOpaqueOnly = value;
  6229. },
  6230. enumerable: true,
  6231. configurable: true
  6232. });
  6233. Object.defineProperty(Image.prototype, "sliceLeft", {
  6234. /**
  6235. * Gets or sets the left value for slicing (9-patch)
  6236. */
  6237. get: function () {
  6238. return this._sliceLeft;
  6239. },
  6240. set: function (value) {
  6241. if (this._sliceLeft === value) {
  6242. return;
  6243. }
  6244. this._sliceLeft = value;
  6245. this._markAsDirty();
  6246. },
  6247. enumerable: true,
  6248. configurable: true
  6249. });
  6250. Object.defineProperty(Image.prototype, "sliceRight", {
  6251. /**
  6252. * Gets or sets the right value for slicing (9-patch)
  6253. */
  6254. get: function () {
  6255. return this._sliceRight;
  6256. },
  6257. set: function (value) {
  6258. if (this._sliceRight === value) {
  6259. return;
  6260. }
  6261. this._sliceRight = value;
  6262. this._markAsDirty();
  6263. },
  6264. enumerable: true,
  6265. configurable: true
  6266. });
  6267. Object.defineProperty(Image.prototype, "sliceTop", {
  6268. /**
  6269. * Gets or sets the top value for slicing (9-patch)
  6270. */
  6271. get: function () {
  6272. return this._sliceTop;
  6273. },
  6274. set: function (value) {
  6275. if (this._sliceTop === value) {
  6276. return;
  6277. }
  6278. this._sliceTop = value;
  6279. this._markAsDirty();
  6280. },
  6281. enumerable: true,
  6282. configurable: true
  6283. });
  6284. Object.defineProperty(Image.prototype, "sliceBottom", {
  6285. /**
  6286. * Gets or sets the bottom value for slicing (9-patch)
  6287. */
  6288. get: function () {
  6289. return this._sliceBottom;
  6290. },
  6291. set: function (value) {
  6292. if (this._sliceBottom === value) {
  6293. return;
  6294. }
  6295. this._sliceBottom = value;
  6296. this._markAsDirty();
  6297. },
  6298. enumerable: true,
  6299. configurable: true
  6300. });
  6301. Object.defineProperty(Image.prototype, "sourceLeft", {
  6302. /**
  6303. * Gets or sets the left coordinate in the source image
  6304. */
  6305. get: function () {
  6306. return this._sourceLeft;
  6307. },
  6308. set: function (value) {
  6309. if (this._sourceLeft === value) {
  6310. return;
  6311. }
  6312. this._sourceLeft = value;
  6313. this._markAsDirty();
  6314. },
  6315. enumerable: true,
  6316. configurable: true
  6317. });
  6318. Object.defineProperty(Image.prototype, "sourceTop", {
  6319. /**
  6320. * Gets or sets the top coordinate in the source image
  6321. */
  6322. get: function () {
  6323. return this._sourceTop;
  6324. },
  6325. set: function (value) {
  6326. if (this._sourceTop === value) {
  6327. return;
  6328. }
  6329. this._sourceTop = value;
  6330. this._markAsDirty();
  6331. },
  6332. enumerable: true,
  6333. configurable: true
  6334. });
  6335. Object.defineProperty(Image.prototype, "sourceWidth", {
  6336. /**
  6337. * Gets or sets the width to capture in the source image
  6338. */
  6339. get: function () {
  6340. return this._sourceWidth;
  6341. },
  6342. set: function (value) {
  6343. if (this._sourceWidth === value) {
  6344. return;
  6345. }
  6346. this._sourceWidth = value;
  6347. this._markAsDirty();
  6348. },
  6349. enumerable: true,
  6350. configurable: true
  6351. });
  6352. Object.defineProperty(Image.prototype, "sourceHeight", {
  6353. /**
  6354. * Gets or sets the height to capture in the source image
  6355. */
  6356. get: function () {
  6357. return this._sourceHeight;
  6358. },
  6359. set: function (value) {
  6360. if (this._sourceHeight === value) {
  6361. return;
  6362. }
  6363. this._sourceHeight = value;
  6364. this._markAsDirty();
  6365. },
  6366. enumerable: true,
  6367. configurable: true
  6368. });
  6369. Object.defineProperty(Image.prototype, "autoScale", {
  6370. /**
  6371. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6372. * @see http://doc.babylonjs.com/how_to/gui#image
  6373. */
  6374. get: function () {
  6375. return this._autoScale;
  6376. },
  6377. set: function (value) {
  6378. if (this._autoScale === value) {
  6379. return;
  6380. }
  6381. this._autoScale = value;
  6382. if (value && this._loaded) {
  6383. this.synchronizeSizeWithContent();
  6384. }
  6385. },
  6386. enumerable: true,
  6387. configurable: true
  6388. });
  6389. Object.defineProperty(Image.prototype, "stretch", {
  6390. /** Gets or sets the streching mode used by the image */
  6391. get: function () {
  6392. return this._stretch;
  6393. },
  6394. set: function (value) {
  6395. if (this._stretch === value) {
  6396. return;
  6397. }
  6398. this._stretch = value;
  6399. this._markAsDirty();
  6400. },
  6401. enumerable: true,
  6402. configurable: true
  6403. });
  6404. Object.defineProperty(Image.prototype, "domImage", {
  6405. get: function () {
  6406. return this._domImage;
  6407. },
  6408. /**
  6409. * Gets or sets the internal DOM image used to render the control
  6410. */
  6411. set: function (value) {
  6412. var _this = this;
  6413. this._domImage = value;
  6414. this._loaded = false;
  6415. if (this._domImage.width) {
  6416. this._onImageLoaded();
  6417. }
  6418. else {
  6419. this._domImage.onload = function () {
  6420. _this._onImageLoaded();
  6421. };
  6422. }
  6423. },
  6424. enumerable: true,
  6425. configurable: true
  6426. });
  6427. Image.prototype._onImageLoaded = function () {
  6428. this._imageWidth = this._domImage.width;
  6429. this._imageHeight = this._domImage.height;
  6430. this._loaded = true;
  6431. if (this._populateNinePatchSlicesFromImage) {
  6432. this._extractNinePatchSliceDataFromImage();
  6433. }
  6434. if (this._autoScale) {
  6435. this.synchronizeSizeWithContent();
  6436. }
  6437. this.onImageLoadedObservable.notifyObservers(this);
  6438. this._markAsDirty();
  6439. };
  6440. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6441. if (!Image._WorkingCanvas) {
  6442. Image._WorkingCanvas = document.createElement('canvas');
  6443. }
  6444. var canvas = Image._WorkingCanvas;
  6445. var context = canvas.getContext('2d');
  6446. var width = this._domImage.width;
  6447. var height = this._domImage.height;
  6448. canvas.width = width;
  6449. canvas.height = height;
  6450. context.drawImage(this._domImage, 0, 0, width, height);
  6451. var imageData = context.getImageData(0, 0, width, height);
  6452. // Left and right
  6453. this._sliceLeft = -1;
  6454. this._sliceRight = -1;
  6455. for (var x = 0; x < width; x++) {
  6456. var alpha = imageData.data[x * 4 + 3];
  6457. if (alpha > 127 && this._sliceLeft === -1) {
  6458. this._sliceLeft = x;
  6459. continue;
  6460. }
  6461. if (alpha < 127 && this._sliceLeft > -1) {
  6462. this._sliceRight = x;
  6463. break;
  6464. }
  6465. }
  6466. // top and bottom
  6467. this._sliceTop = -1;
  6468. this._sliceBottom = -1;
  6469. for (var y = 0; y < height; y++) {
  6470. var alpha = imageData.data[y * width * 4 + 3];
  6471. if (alpha > 127 && this._sliceTop === -1) {
  6472. this._sliceTop = y;
  6473. continue;
  6474. }
  6475. if (alpha < 127 && this._sliceTop > -1) {
  6476. this._sliceBottom = y;
  6477. break;
  6478. }
  6479. }
  6480. };
  6481. Object.defineProperty(Image.prototype, "source", {
  6482. /**
  6483. * Gets or sets image source url
  6484. */
  6485. set: function (value) {
  6486. var _this = this;
  6487. if (this._source === value) {
  6488. return;
  6489. }
  6490. this._loaded = false;
  6491. this._source = value;
  6492. if (value) {
  6493. this._svgCheck(value);
  6494. }
  6495. this._domImage = document.createElement("img");
  6496. this._domImage.onload = function () {
  6497. _this._onImageLoaded();
  6498. };
  6499. if (value) {
  6500. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6501. this._domImage.src = value;
  6502. }
  6503. },
  6504. enumerable: true,
  6505. configurable: true
  6506. });
  6507. /**
  6508. * Checks for svg document with icon id present
  6509. */
  6510. Image.prototype._svgCheck = function (value) {
  6511. var _this = this;
  6512. if ((value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6513. var svgsrc = value.split('#')[0];
  6514. var elemid = value.split('#')[1];
  6515. // check if object alr exist in document
  6516. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6517. if (svgExist) {
  6518. if (svgExist.contentDocument) {
  6519. // svg object alr exists
  6520. this._getSVGAttribs(svgExist, elemid);
  6521. }
  6522. else {
  6523. // wait for object to load
  6524. svgExist.addEventListener("load", function () {
  6525. _this._getSVGAttribs(svgExist, elemid);
  6526. });
  6527. }
  6528. }
  6529. else {
  6530. // create document object
  6531. var svgImage = document.createElement("object");
  6532. svgImage.data = svgsrc;
  6533. svgImage.type = "image/svg+xml";
  6534. svgImage.width = "0%";
  6535. svgImage.height = "0%";
  6536. document.body.appendChild(svgImage);
  6537. // when the object has loaded, get the element attribs
  6538. svgImage.onload = function () {
  6539. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6540. if (svgobj) {
  6541. _this._getSVGAttribs(svgobj, elemid);
  6542. }
  6543. };
  6544. }
  6545. }
  6546. };
  6547. /**
  6548. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6549. * given external svg file and icon id
  6550. */
  6551. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6552. var svgDoc = svgsrc.contentDocument;
  6553. // get viewbox width and height, get svg document width and height in px
  6554. if (svgDoc && svgDoc.documentElement) {
  6555. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6556. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6557. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6558. // get element bbox and matrix transform
  6559. var elem = svgDoc.getElementById(elemid);
  6560. if (elem instanceof SVGElement && vb && docwidth && docheight) {
  6561. var vb_width = Number(vb.split(" ")[2]);
  6562. var vb_height = Number(vb.split(" ")[3]);
  6563. var elem_bbox = elem.getBBox();
  6564. var elem_matrix_a = 1;
  6565. var elem_matrix_d = 1;
  6566. var elem_matrix_e = 0;
  6567. var elem_matrix_f = 0;
  6568. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6569. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6570. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6571. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6572. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6573. }
  6574. // compute source coordinates and dimensions
  6575. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6576. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6577. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6578. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6579. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6580. }
  6581. }
  6582. };
  6583. Object.defineProperty(Image.prototype, "cellWidth", {
  6584. /**
  6585. * Gets or sets the cell width to use when animation sheet is enabled
  6586. * @see http://doc.babylonjs.com/how_to/gui#image
  6587. */
  6588. get: function () {
  6589. return this._cellWidth;
  6590. },
  6591. set: function (value) {
  6592. if (this._cellWidth === value) {
  6593. return;
  6594. }
  6595. this._cellWidth = value;
  6596. this._markAsDirty();
  6597. },
  6598. enumerable: true,
  6599. configurable: true
  6600. });
  6601. Object.defineProperty(Image.prototype, "cellHeight", {
  6602. /**
  6603. * Gets or sets the cell height to use when animation sheet is enabled
  6604. * @see http://doc.babylonjs.com/how_to/gui#image
  6605. */
  6606. get: function () {
  6607. return this._cellHeight;
  6608. },
  6609. set: function (value) {
  6610. if (this._cellHeight === value) {
  6611. return;
  6612. }
  6613. this._cellHeight = value;
  6614. this._markAsDirty();
  6615. },
  6616. enumerable: true,
  6617. configurable: true
  6618. });
  6619. Object.defineProperty(Image.prototype, "cellId", {
  6620. /**
  6621. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6622. * @see http://doc.babylonjs.com/how_to/gui#image
  6623. */
  6624. get: function () {
  6625. return this._cellId;
  6626. },
  6627. set: function (value) {
  6628. if (this._cellId === value) {
  6629. return;
  6630. }
  6631. this._cellId = value;
  6632. this._markAsDirty();
  6633. },
  6634. enumerable: true,
  6635. configurable: true
  6636. });
  6637. /**
  6638. * Tests if a given coordinates belong to the current control
  6639. * @param x defines x coordinate to test
  6640. * @param y defines y coordinate to test
  6641. * @returns true if the coordinates are inside the control
  6642. */
  6643. Image.prototype.contains = function (x, y) {
  6644. if (!_super.prototype.contains.call(this, x, y)) {
  6645. return false;
  6646. }
  6647. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6648. return true;
  6649. }
  6650. var canvas = Image._WorkingCanvas;
  6651. var context = canvas.getContext("2d");
  6652. var width = this._currentMeasure.width | 0;
  6653. var height = this._currentMeasure.height | 0;
  6654. var imageData = context.getImageData(0, 0, width, height).data;
  6655. x = (x - this._currentMeasure.left) | 0;
  6656. y = (y - this._currentMeasure.top) | 0;
  6657. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6658. return pickedPixel > 0;
  6659. };
  6660. Image.prototype._getTypeName = function () {
  6661. return "Image";
  6662. };
  6663. /** Force the control to synchronize with its content */
  6664. Image.prototype.synchronizeSizeWithContent = function () {
  6665. if (!this._loaded) {
  6666. return;
  6667. }
  6668. this.width = this._domImage.width + "px";
  6669. this.height = this._domImage.height + "px";
  6670. };
  6671. Image.prototype._processMeasures = function (parentMeasure, context) {
  6672. if (this._loaded) {
  6673. switch (this._stretch) {
  6674. case Image.STRETCH_NONE:
  6675. break;
  6676. case Image.STRETCH_FILL:
  6677. break;
  6678. case Image.STRETCH_UNIFORM:
  6679. break;
  6680. case Image.STRETCH_NINE_PATCH:
  6681. break;
  6682. case Image.STRETCH_EXTEND:
  6683. if (this._autoScale) {
  6684. this.synchronizeSizeWithContent();
  6685. }
  6686. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6687. this.parent.adaptWidthToChildren = true;
  6688. this.parent.adaptHeightToChildren = true;
  6689. }
  6690. break;
  6691. }
  6692. }
  6693. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6694. };
  6695. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6696. if (!this._detectPointerOnOpaqueOnly) {
  6697. return;
  6698. }
  6699. if (!Image._WorkingCanvas) {
  6700. Image._WorkingCanvas = document.createElement('canvas');
  6701. }
  6702. var canvas = Image._WorkingCanvas;
  6703. var width = this._currentMeasure.width;
  6704. var height = this._currentMeasure.height;
  6705. var context = canvas.getContext("2d");
  6706. canvas.width = width;
  6707. canvas.height = height;
  6708. context.clearRect(0, 0, width, height);
  6709. };
  6710. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6711. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6712. if (!this._detectPointerOnOpaqueOnly) {
  6713. return;
  6714. }
  6715. var canvas = Image._WorkingCanvas;
  6716. context = canvas.getContext("2d");
  6717. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6718. };
  6719. Image.prototype._draw = function (context) {
  6720. context.save();
  6721. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6722. context.shadowColor = this.shadowColor;
  6723. context.shadowBlur = this.shadowBlur;
  6724. context.shadowOffsetX = this.shadowOffsetX;
  6725. context.shadowOffsetY = this.shadowOffsetY;
  6726. }
  6727. var x, y, width, height;
  6728. if (this.cellId == -1) {
  6729. x = this._sourceLeft;
  6730. y = this._sourceTop;
  6731. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6732. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6733. }
  6734. else {
  6735. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6736. var column = (this.cellId / rowCount) >> 0;
  6737. var row = this.cellId % rowCount;
  6738. x = this.cellWidth * row;
  6739. y = this.cellHeight * column;
  6740. width = this.cellWidth;
  6741. height = this.cellHeight;
  6742. }
  6743. this._prepareWorkingCanvasForOpaqueDetection();
  6744. this._applyStates(context);
  6745. if (this._loaded) {
  6746. switch (this._stretch) {
  6747. case Image.STRETCH_NONE:
  6748. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6749. break;
  6750. case Image.STRETCH_FILL:
  6751. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6752. break;
  6753. case Image.STRETCH_UNIFORM:
  6754. var hRatio = this._currentMeasure.width / width;
  6755. var vRatio = this._currentMeasure.height / height;
  6756. var ratio = Math.min(hRatio, vRatio);
  6757. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6758. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6759. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6760. break;
  6761. case Image.STRETCH_EXTEND:
  6762. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6763. break;
  6764. case Image.STRETCH_NINE_PATCH:
  6765. this._renderNinePatch(context);
  6766. break;
  6767. }
  6768. }
  6769. context.restore();
  6770. };
  6771. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6772. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6773. };
  6774. Image.prototype._renderNinePatch = function (context) {
  6775. var height = this._imageHeight;
  6776. var leftWidth = this._sliceLeft;
  6777. var topHeight = this._sliceTop;
  6778. var bottomHeight = this._imageHeight - this._sliceBottom;
  6779. var rightWidth = this._imageWidth - this._sliceRight;
  6780. var left = 0;
  6781. var top = 0;
  6782. if (this._populateNinePatchSlicesFromImage) {
  6783. left = 1;
  6784. top = 1;
  6785. height -= 2;
  6786. leftWidth -= 1;
  6787. topHeight -= 1;
  6788. bottomHeight -= 1;
  6789. rightWidth -= 1;
  6790. }
  6791. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6792. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6793. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6794. // Corners
  6795. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6796. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6797. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6798. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6799. // Center
  6800. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6801. // Borders
  6802. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6803. 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);
  6804. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6805. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6806. };
  6807. Image.prototype.dispose = function () {
  6808. _super.prototype.dispose.call(this);
  6809. this.onImageLoadedObservable.clear();
  6810. this.onSVGAttributesComputedObservable.clear();
  6811. };
  6812. Image._WorkingCanvas = null;
  6813. // Static
  6814. /** STRETCH_NONE */
  6815. Image.STRETCH_NONE = 0;
  6816. /** STRETCH_FILL */
  6817. Image.STRETCH_FILL = 1;
  6818. /** STRETCH_UNIFORM */
  6819. Image.STRETCH_UNIFORM = 2;
  6820. /** STRETCH_EXTEND */
  6821. Image.STRETCH_EXTEND = 3;
  6822. /** NINE_PATCH */
  6823. Image.STRETCH_NINE_PATCH = 4;
  6824. return Image;
  6825. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6826. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6827. /***/ }),
  6828. /***/ "./2D/controls/index.ts":
  6829. /*!******************************!*\
  6830. !*** ./2D/controls/index.ts ***!
  6831. \******************************/
  6832. /*! 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, name */
  6833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6834. "use strict";
  6835. __webpack_require__.r(__webpack_exports__);
  6836. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6838. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6840. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6842. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6844. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6846. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6848. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6850. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6852. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6854. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6856. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6858. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6860. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6862. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6864. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6870. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6872. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6875. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6878. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6880. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6882. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6884. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6886. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6888. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6890. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6892. /***/ }),
  6893. /***/ "./2D/controls/inputPassword.ts":
  6894. /*!**************************************!*\
  6895. !*** ./2D/controls/inputPassword.ts ***!
  6896. \**************************************/
  6897. /*! exports provided: InputPassword */
  6898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6899. "use strict";
  6900. __webpack_require__.r(__webpack_exports__);
  6901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6902. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6903. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6904. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  6905. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6906. /**
  6907. * Class used to create a password control
  6908. */
  6909. var InputPassword = /** @class */ (function (_super) {
  6910. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6911. function InputPassword() {
  6912. return _super !== null && _super.apply(this, arguments) || this;
  6913. }
  6914. InputPassword.prototype._beforeRenderText = function (text) {
  6915. var txt = "";
  6916. for (var i = 0; i < text.length; i++) {
  6917. txt += "\u2022";
  6918. }
  6919. return txt;
  6920. };
  6921. return InputPassword;
  6922. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6923. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6924. /***/ }),
  6925. /***/ "./2D/controls/inputText.ts":
  6926. /*!**********************************!*\
  6927. !*** ./2D/controls/inputText.ts ***!
  6928. \**********************************/
  6929. /*! exports provided: InputText */
  6930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6931. "use strict";
  6932. __webpack_require__.r(__webpack_exports__);
  6933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6935. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6936. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6937. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6938. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6939. /**
  6940. * Class used to create input text control
  6941. */
  6942. var InputText = /** @class */ (function (_super) {
  6943. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6944. /**
  6945. * Creates a new InputText
  6946. * @param name defines the control name
  6947. * @param text defines the text of the control
  6948. */
  6949. function InputText(name, text) {
  6950. if (text === void 0) { text = ""; }
  6951. var _this = _super.call(this, name) || this;
  6952. _this.name = name;
  6953. _this._text = "";
  6954. _this._placeholderText = "";
  6955. _this._background = "#222222";
  6956. _this._focusedBackground = "#000000";
  6957. _this._focusedColor = "white";
  6958. _this._placeholderColor = "gray";
  6959. _this._thickness = 1;
  6960. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6961. _this._autoStretchWidth = true;
  6962. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6963. _this._isFocused = false;
  6964. _this._blinkIsEven = false;
  6965. _this._cursorOffset = 0;
  6966. _this._deadKey = false;
  6967. _this._addKey = true;
  6968. _this._currentKey = "";
  6969. _this._isTextHighlightOn = false;
  6970. _this._textHighlightColor = "#d5e0ff";
  6971. _this._highligherOpacity = 0.4;
  6972. _this._highlightedText = "";
  6973. _this._startHighlightIndex = 0;
  6974. _this._endHighlightIndex = 0;
  6975. _this._cursorIndex = -1;
  6976. _this._onFocusSelectAll = false;
  6977. _this._isPointerDown = false;
  6978. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6979. _this.promptMessage = "Please enter text:";
  6980. /** Force disable prompt on mobile device */
  6981. _this.disableMobilePrompt = false;
  6982. /** Observable raised when the text changes */
  6983. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6984. /** Observable raised just before an entered character is to be added */
  6985. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6986. /** Observable raised when the control gets the focus */
  6987. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6988. /** Observable raised when the control loses the focus */
  6989. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6990. /**Observable raised when the text is highlighted */
  6991. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6992. /**Observable raised when copy event is triggered */
  6993. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6994. /** Observable raised when cut event is triggered */
  6995. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6996. /** Observable raised when paste event is triggered */
  6997. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6998. /** Observable raised when a key event was processed */
  6999. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7000. _this.text = text;
  7001. _this.isPointerBlocker = true;
  7002. return _this;
  7003. }
  7004. Object.defineProperty(InputText.prototype, "maxWidth", {
  7005. /** Gets or sets the maximum width allowed by the control */
  7006. get: function () {
  7007. return this._maxWidth.toString(this._host);
  7008. },
  7009. set: function (value) {
  7010. if (this._maxWidth.toString(this._host) === value) {
  7011. return;
  7012. }
  7013. if (this._maxWidth.fromString(value)) {
  7014. this._markAsDirty();
  7015. }
  7016. },
  7017. enumerable: true,
  7018. configurable: true
  7019. });
  7020. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7021. /** Gets the maximum width allowed by the control in pixels */
  7022. get: function () {
  7023. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7024. },
  7025. enumerable: true,
  7026. configurable: true
  7027. });
  7028. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7029. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7030. get: function () {
  7031. return this._highligherOpacity;
  7032. },
  7033. set: function (value) {
  7034. if (this._highligherOpacity === value) {
  7035. return;
  7036. }
  7037. this._highligherOpacity = value;
  7038. this._markAsDirty();
  7039. },
  7040. enumerable: true,
  7041. configurable: true
  7042. });
  7043. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7044. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7045. get: function () {
  7046. return this._onFocusSelectAll;
  7047. },
  7048. set: function (value) {
  7049. if (this._onFocusSelectAll === value) {
  7050. return;
  7051. }
  7052. this._onFocusSelectAll = value;
  7053. this._markAsDirty();
  7054. },
  7055. enumerable: true,
  7056. configurable: true
  7057. });
  7058. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7059. /** Gets or sets the text hightlight color */
  7060. get: function () {
  7061. return this._textHighlightColor;
  7062. },
  7063. set: function (value) {
  7064. if (this._textHighlightColor === value) {
  7065. return;
  7066. }
  7067. this._textHighlightColor = value;
  7068. this._markAsDirty();
  7069. },
  7070. enumerable: true,
  7071. configurable: true
  7072. });
  7073. Object.defineProperty(InputText.prototype, "margin", {
  7074. /** Gets or sets control margin */
  7075. get: function () {
  7076. return this._margin.toString(this._host);
  7077. },
  7078. set: function (value) {
  7079. if (this._margin.toString(this._host) === value) {
  7080. return;
  7081. }
  7082. if (this._margin.fromString(value)) {
  7083. this._markAsDirty();
  7084. }
  7085. },
  7086. enumerable: true,
  7087. configurable: true
  7088. });
  7089. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7090. /** Gets control margin in pixels */
  7091. get: function () {
  7092. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7093. },
  7094. enumerable: true,
  7095. configurable: true
  7096. });
  7097. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7098. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7099. get: function () {
  7100. return this._autoStretchWidth;
  7101. },
  7102. set: function (value) {
  7103. if (this._autoStretchWidth === value) {
  7104. return;
  7105. }
  7106. this._autoStretchWidth = value;
  7107. this._markAsDirty();
  7108. },
  7109. enumerable: true,
  7110. configurable: true
  7111. });
  7112. Object.defineProperty(InputText.prototype, "thickness", {
  7113. /** Gets or sets border thickness */
  7114. get: function () {
  7115. return this._thickness;
  7116. },
  7117. set: function (value) {
  7118. if (this._thickness === value) {
  7119. return;
  7120. }
  7121. this._thickness = value;
  7122. this._markAsDirty();
  7123. },
  7124. enumerable: true,
  7125. configurable: true
  7126. });
  7127. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7128. /** Gets or sets the background color when focused */
  7129. get: function () {
  7130. return this._focusedBackground;
  7131. },
  7132. set: function (value) {
  7133. if (this._focusedBackground === value) {
  7134. return;
  7135. }
  7136. this._focusedBackground = value;
  7137. this._markAsDirty();
  7138. },
  7139. enumerable: true,
  7140. configurable: true
  7141. });
  7142. Object.defineProperty(InputText.prototype, "focusedColor", {
  7143. /** Gets or sets the background color when focused */
  7144. get: function () {
  7145. return this._focusedColor;
  7146. },
  7147. set: function (value) {
  7148. if (this._focusedColor === value) {
  7149. return;
  7150. }
  7151. this._focusedColor = value;
  7152. this._markAsDirty();
  7153. },
  7154. enumerable: true,
  7155. configurable: true
  7156. });
  7157. Object.defineProperty(InputText.prototype, "background", {
  7158. /** Gets or sets the background color */
  7159. get: function () {
  7160. return this._background;
  7161. },
  7162. set: function (value) {
  7163. if (this._background === value) {
  7164. return;
  7165. }
  7166. this._background = value;
  7167. this._markAsDirty();
  7168. },
  7169. enumerable: true,
  7170. configurable: true
  7171. });
  7172. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7173. /** Gets or sets the placeholder color */
  7174. get: function () {
  7175. return this._placeholderColor;
  7176. },
  7177. set: function (value) {
  7178. if (this._placeholderColor === value) {
  7179. return;
  7180. }
  7181. this._placeholderColor = value;
  7182. this._markAsDirty();
  7183. },
  7184. enumerable: true,
  7185. configurable: true
  7186. });
  7187. Object.defineProperty(InputText.prototype, "placeholderText", {
  7188. /** Gets or sets the text displayed when the control is empty */
  7189. get: function () {
  7190. return this._placeholderText;
  7191. },
  7192. set: function (value) {
  7193. if (this._placeholderText === value) {
  7194. return;
  7195. }
  7196. this._placeholderText = value;
  7197. this._markAsDirty();
  7198. },
  7199. enumerable: true,
  7200. configurable: true
  7201. });
  7202. Object.defineProperty(InputText.prototype, "deadKey", {
  7203. /** Gets or sets the dead key flag */
  7204. get: function () {
  7205. return this._deadKey;
  7206. },
  7207. set: function (flag) {
  7208. this._deadKey = flag;
  7209. },
  7210. enumerable: true,
  7211. configurable: true
  7212. });
  7213. Object.defineProperty(InputText.prototype, "highlightedText", {
  7214. /** Gets or sets the highlight text */
  7215. get: function () {
  7216. return this._highlightedText;
  7217. },
  7218. set: function (text) {
  7219. if (this._highlightedText === text) {
  7220. return;
  7221. }
  7222. this._highlightedText = text;
  7223. this._markAsDirty();
  7224. },
  7225. enumerable: true,
  7226. configurable: true
  7227. });
  7228. Object.defineProperty(InputText.prototype, "addKey", {
  7229. /** Gets or sets if the current key should be added */
  7230. get: function () {
  7231. return this._addKey;
  7232. },
  7233. set: function (flag) {
  7234. this._addKey = flag;
  7235. },
  7236. enumerable: true,
  7237. configurable: true
  7238. });
  7239. Object.defineProperty(InputText.prototype, "currentKey", {
  7240. /** Gets or sets the value of the current key being entered */
  7241. get: function () {
  7242. return this._currentKey;
  7243. },
  7244. set: function (key) {
  7245. this._currentKey = key;
  7246. },
  7247. enumerable: true,
  7248. configurable: true
  7249. });
  7250. Object.defineProperty(InputText.prototype, "text", {
  7251. /** Gets or sets the text displayed in the control */
  7252. get: function () {
  7253. return this._text;
  7254. },
  7255. set: function (value) {
  7256. var valueAsString = value.toString(); // Forcing convertion
  7257. if (this._text === valueAsString) {
  7258. return;
  7259. }
  7260. this._text = valueAsString;
  7261. this._markAsDirty();
  7262. this.onTextChangedObservable.notifyObservers(this);
  7263. },
  7264. enumerable: true,
  7265. configurable: true
  7266. });
  7267. Object.defineProperty(InputText.prototype, "width", {
  7268. /** Gets or sets control width */
  7269. get: function () {
  7270. return this._width.toString(this._host);
  7271. },
  7272. set: function (value) {
  7273. if (this._width.toString(this._host) === value) {
  7274. return;
  7275. }
  7276. if (this._width.fromString(value)) {
  7277. this._markAsDirty();
  7278. }
  7279. this.autoStretchWidth = false;
  7280. },
  7281. enumerable: true,
  7282. configurable: true
  7283. });
  7284. /** @hidden */
  7285. InputText.prototype.onBlur = function () {
  7286. this._isFocused = false;
  7287. this._scrollLeft = null;
  7288. this._cursorOffset = 0;
  7289. clearTimeout(this._blinkTimeout);
  7290. this._markAsDirty();
  7291. this.onBlurObservable.notifyObservers(this);
  7292. this._host.unRegisterClipboardEvents();
  7293. if (this._onClipboardObserver) {
  7294. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7295. }
  7296. var scene = this._host.getScene();
  7297. if (this._onPointerDblTapObserver && scene) {
  7298. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7299. }
  7300. };
  7301. /** @hidden */
  7302. InputText.prototype.onFocus = function () {
  7303. var _this = this;
  7304. if (!this._isEnabled) {
  7305. return;
  7306. }
  7307. this._scrollLeft = null;
  7308. this._isFocused = true;
  7309. this._blinkIsEven = false;
  7310. this._cursorOffset = 0;
  7311. this._markAsDirty();
  7312. this.onFocusObservable.notifyObservers(this);
  7313. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7314. var value = prompt(this.promptMessage);
  7315. if (value !== null) {
  7316. this.text = value;
  7317. }
  7318. this._host.focusedControl = null;
  7319. return;
  7320. }
  7321. this._host.registerClipboardEvents();
  7322. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7323. // process clipboard event, can be configured.
  7324. switch (clipboardInfo.type) {
  7325. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7326. _this._onCopyText(clipboardInfo.event);
  7327. _this.onTextCopyObservable.notifyObservers(_this);
  7328. break;
  7329. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7330. _this._onCutText(clipboardInfo.event);
  7331. _this.onTextCutObservable.notifyObservers(_this);
  7332. break;
  7333. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7334. _this._onPasteText(clipboardInfo.event);
  7335. _this.onTextPasteObservable.notifyObservers(_this);
  7336. break;
  7337. default: return;
  7338. }
  7339. });
  7340. var scene = this._host.getScene();
  7341. if (scene) {
  7342. //register the pointer double tap event
  7343. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7344. if (!_this._isFocused) {
  7345. return;
  7346. }
  7347. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7348. _this._processDblClick(pointerInfo);
  7349. }
  7350. });
  7351. }
  7352. if (this._onFocusSelectAll) {
  7353. this._selectAllText();
  7354. }
  7355. };
  7356. InputText.prototype._getTypeName = function () {
  7357. return "InputText";
  7358. };
  7359. /**
  7360. * Function called to get the list of controls that should not steal the focus from this control
  7361. * @returns an array of controls
  7362. */
  7363. InputText.prototype.keepsFocusWith = function () {
  7364. if (!this._connectedVirtualKeyboard) {
  7365. return null;
  7366. }
  7367. return [this._connectedVirtualKeyboard];
  7368. };
  7369. /** @hidden */
  7370. InputText.prototype.processKey = function (keyCode, key, evt) {
  7371. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7372. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7373. return;
  7374. }
  7375. //select all
  7376. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7377. this._selectAllText();
  7378. evt.preventDefault();
  7379. return;
  7380. }
  7381. // Specific cases
  7382. switch (keyCode) {
  7383. case 32: //SPACE
  7384. key = " "; //ie11 key for space is "Spacebar"
  7385. break;
  7386. case 191: //SLASH
  7387. if (evt) {
  7388. evt.preventDefault();
  7389. }
  7390. break;
  7391. case 8: // BACKSPACE
  7392. if (this._text && this._text.length > 0) {
  7393. //delete the highlighted text
  7394. if (this._isTextHighlightOn) {
  7395. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7396. this._isTextHighlightOn = false;
  7397. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7398. this._blinkIsEven = false;
  7399. if (evt) {
  7400. evt.preventDefault();
  7401. }
  7402. return;
  7403. }
  7404. //delete single character
  7405. if (this._cursorOffset === 0) {
  7406. this.text = this._text.substr(0, this._text.length - 1);
  7407. }
  7408. else {
  7409. var deletePosition = this._text.length - this._cursorOffset;
  7410. if (deletePosition > 0) {
  7411. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7412. }
  7413. }
  7414. }
  7415. if (evt) {
  7416. evt.preventDefault();
  7417. }
  7418. return;
  7419. case 46: // DELETE
  7420. if (this._isTextHighlightOn) {
  7421. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7422. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7423. while (decrementor > 0 && this._cursorOffset > 0) {
  7424. this._cursorOffset--;
  7425. }
  7426. this._isTextHighlightOn = false;
  7427. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7428. if (evt) {
  7429. evt.preventDefault();
  7430. }
  7431. return;
  7432. }
  7433. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7434. var deletePosition = this._text.length - this._cursorOffset;
  7435. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7436. this._cursorOffset--;
  7437. }
  7438. if (evt) {
  7439. evt.preventDefault();
  7440. }
  7441. return;
  7442. case 13: // RETURN
  7443. this._host.focusedControl = null;
  7444. this._isTextHighlightOn = false;
  7445. return;
  7446. case 35: // END
  7447. this._cursorOffset = 0;
  7448. this._blinkIsEven = false;
  7449. this._isTextHighlightOn = false;
  7450. this._markAsDirty();
  7451. return;
  7452. case 36: // HOME
  7453. this._cursorOffset = this._text.length;
  7454. this._blinkIsEven = false;
  7455. this._isTextHighlightOn = false;
  7456. this._markAsDirty();
  7457. return;
  7458. case 37: // LEFT
  7459. this._cursorOffset++;
  7460. if (this._cursorOffset > this._text.length) {
  7461. this._cursorOffset = this._text.length;
  7462. }
  7463. if (evt && evt.shiftKey) {
  7464. // update the cursor
  7465. this._blinkIsEven = false;
  7466. // shift + ctrl/cmd + <-
  7467. if (evt.ctrlKey || evt.metaKey) {
  7468. if (!this._isTextHighlightOn) {
  7469. if (this._text.length === this._cursorOffset) {
  7470. return;
  7471. }
  7472. else {
  7473. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7474. }
  7475. }
  7476. this._startHighlightIndex = 0;
  7477. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7478. this._cursorOffset = this._text.length;
  7479. this._isTextHighlightOn = true;
  7480. this._markAsDirty();
  7481. return;
  7482. }
  7483. //store the starting point
  7484. if (!this._isTextHighlightOn) {
  7485. this._isTextHighlightOn = true;
  7486. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7487. }
  7488. //if text is already highlighted
  7489. else if (this._cursorIndex === -1) {
  7490. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7491. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7492. }
  7493. //set the highlight indexes
  7494. if (this._cursorIndex < this._cursorOffset) {
  7495. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7496. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7497. }
  7498. else if (this._cursorIndex > this._cursorOffset) {
  7499. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7500. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7501. }
  7502. else {
  7503. this._isTextHighlightOn = false;
  7504. }
  7505. this._markAsDirty();
  7506. return;
  7507. }
  7508. if (this._isTextHighlightOn) {
  7509. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7510. this._isTextHighlightOn = false;
  7511. }
  7512. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7513. this._cursorOffset = this.text.length;
  7514. evt.preventDefault();
  7515. }
  7516. this._blinkIsEven = false;
  7517. this._isTextHighlightOn = false;
  7518. this._cursorIndex = -1;
  7519. this._markAsDirty();
  7520. return;
  7521. case 39: // RIGHT
  7522. this._cursorOffset--;
  7523. if (this._cursorOffset < 0) {
  7524. this._cursorOffset = 0;
  7525. }
  7526. if (evt && evt.shiftKey) {
  7527. //update the cursor
  7528. this._blinkIsEven = false;
  7529. //shift + ctrl/cmd + ->
  7530. if (evt.ctrlKey || evt.metaKey) {
  7531. if (!this._isTextHighlightOn) {
  7532. if (this._cursorOffset === 0) {
  7533. return;
  7534. }
  7535. else {
  7536. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7537. }
  7538. }
  7539. this._endHighlightIndex = this._text.length;
  7540. this._isTextHighlightOn = true;
  7541. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7542. this._cursorOffset = 0;
  7543. this._markAsDirty();
  7544. return;
  7545. }
  7546. if (!this._isTextHighlightOn) {
  7547. this._isTextHighlightOn = true;
  7548. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7549. }
  7550. //if text is already highlighted
  7551. else if (this._cursorIndex === -1) {
  7552. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7553. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7554. }
  7555. //set the highlight indexes
  7556. if (this._cursorIndex < this._cursorOffset) {
  7557. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7558. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7559. }
  7560. else if (this._cursorIndex > this._cursorOffset) {
  7561. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7562. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7563. }
  7564. else {
  7565. this._isTextHighlightOn = false;
  7566. }
  7567. this._markAsDirty();
  7568. return;
  7569. }
  7570. if (this._isTextHighlightOn) {
  7571. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7572. this._isTextHighlightOn = false;
  7573. }
  7574. //ctr + ->
  7575. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7576. this._cursorOffset = 0;
  7577. evt.preventDefault();
  7578. }
  7579. this._blinkIsEven = false;
  7580. this._isTextHighlightOn = false;
  7581. this._cursorIndex = -1;
  7582. this._markAsDirty();
  7583. return;
  7584. case 222: // Dead
  7585. if (evt) {
  7586. evt.preventDefault();
  7587. }
  7588. this._cursorIndex = -1;
  7589. this.deadKey = true;
  7590. break;
  7591. }
  7592. // Printable characters
  7593. if (key &&
  7594. ((keyCode === -1) || // Direct access
  7595. (keyCode === 32) || // Space
  7596. (keyCode > 47 && keyCode < 64) || // Numbers
  7597. (keyCode > 64 && keyCode < 91) || // Letters
  7598. (keyCode > 159 && keyCode < 193) || // Special characters
  7599. (keyCode > 218 && keyCode < 223) || // Special characters
  7600. (keyCode > 95 && keyCode < 112))) { // Numpad
  7601. this._currentKey = key;
  7602. this.onBeforeKeyAddObservable.notifyObservers(this);
  7603. key = this._currentKey;
  7604. if (this._addKey) {
  7605. if (this._isTextHighlightOn) {
  7606. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7607. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7608. this._isTextHighlightOn = false;
  7609. this._blinkIsEven = false;
  7610. this._markAsDirty();
  7611. }
  7612. else if (this._cursorOffset === 0) {
  7613. this.text += key;
  7614. }
  7615. else {
  7616. var insertPosition = this._text.length - this._cursorOffset;
  7617. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7618. }
  7619. }
  7620. }
  7621. };
  7622. /** @hidden */
  7623. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7624. //update the cursor
  7625. this._blinkIsEven = false;
  7626. if (this._cursorIndex === -1) {
  7627. this._cursorIndex = offset;
  7628. }
  7629. else {
  7630. if (this._cursorIndex < this._cursorOffset) {
  7631. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7632. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7633. }
  7634. else if (this._cursorIndex > this._cursorOffset) {
  7635. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7636. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7637. }
  7638. else {
  7639. this._isTextHighlightOn = false;
  7640. this._markAsDirty();
  7641. return;
  7642. }
  7643. }
  7644. this._isTextHighlightOn = true;
  7645. this._markAsDirty();
  7646. };
  7647. /** @hidden */
  7648. InputText.prototype._processDblClick = function (evt) {
  7649. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7650. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7651. this._endHighlightIndex = this._startHighlightIndex;
  7652. var rWord = /\w+/g, moveLeft, moveRight;
  7653. do {
  7654. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7655. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7656. } while (moveLeft || moveRight);
  7657. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7658. this.onTextHighlightObservable.notifyObservers(this);
  7659. this._isTextHighlightOn = true;
  7660. this._clickedCoordinate = null;
  7661. this._blinkIsEven = true;
  7662. this._cursorIndex = -1;
  7663. this._markAsDirty();
  7664. };
  7665. /** @hidden */
  7666. InputText.prototype._selectAllText = function () {
  7667. this._blinkIsEven = true;
  7668. this._isTextHighlightOn = true;
  7669. this._startHighlightIndex = 0;
  7670. this._endHighlightIndex = this._text.length;
  7671. this._cursorOffset = this._text.length;
  7672. this._cursorIndex = -1;
  7673. this._markAsDirty();
  7674. };
  7675. /**
  7676. * Handles the keyboard event
  7677. * @param evt Defines the KeyboardEvent
  7678. */
  7679. InputText.prototype.processKeyboard = function (evt) {
  7680. // process pressed key
  7681. this.processKey(evt.keyCode, evt.key, evt);
  7682. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7683. };
  7684. /** @hidden */
  7685. InputText.prototype._onCopyText = function (ev) {
  7686. this._isTextHighlightOn = false;
  7687. //when write permission to clipbaord data is denied
  7688. try {
  7689. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7690. }
  7691. catch (_a) { } //pass
  7692. this._host.clipboardData = this._highlightedText;
  7693. };
  7694. /** @hidden */
  7695. InputText.prototype._onCutText = function (ev) {
  7696. if (!this._highlightedText) {
  7697. return;
  7698. }
  7699. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7700. this._isTextHighlightOn = false;
  7701. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7702. //when write permission to clipbaord data is denied
  7703. try {
  7704. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7705. }
  7706. catch (_a) { } //pass
  7707. this._host.clipboardData = this._highlightedText;
  7708. this._highlightedText = "";
  7709. };
  7710. /** @hidden */
  7711. InputText.prototype._onPasteText = function (ev) {
  7712. var data = "";
  7713. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7714. data = ev.clipboardData.getData("text/plain");
  7715. }
  7716. else {
  7717. //get the cached data; returns blank string by default
  7718. data = this._host.clipboardData;
  7719. }
  7720. var insertPosition = this._text.length - this._cursorOffset;
  7721. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7722. };
  7723. InputText.prototype._draw = function (context) {
  7724. var _this = this;
  7725. context.save();
  7726. this._applyStates(context);
  7727. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7728. context.shadowColor = this.shadowColor;
  7729. context.shadowBlur = this.shadowBlur;
  7730. context.shadowOffsetX = this.shadowOffsetX;
  7731. context.shadowOffsetY = this.shadowOffsetY;
  7732. }
  7733. // Background
  7734. if (this._isFocused) {
  7735. if (this._focusedBackground) {
  7736. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7737. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7738. }
  7739. }
  7740. else if (this._background) {
  7741. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7742. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7743. }
  7744. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7745. context.shadowBlur = 0;
  7746. context.shadowOffsetX = 0;
  7747. context.shadowOffsetY = 0;
  7748. }
  7749. if (!this._fontOffset) {
  7750. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7751. }
  7752. // Text
  7753. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7754. if (this.color) {
  7755. context.fillStyle = this.color;
  7756. }
  7757. var text = this._beforeRenderText(this._text);
  7758. if (!this._isFocused && !this._text && this._placeholderText) {
  7759. text = this._placeholderText;
  7760. if (this._placeholderColor) {
  7761. context.fillStyle = this._placeholderColor;
  7762. }
  7763. }
  7764. this._textWidth = context.measureText(text).width;
  7765. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7766. if (this._autoStretchWidth) {
  7767. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7768. }
  7769. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7770. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7771. context.save();
  7772. context.beginPath();
  7773. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7774. context.clip();
  7775. if (this._isFocused && this._textWidth > availableWidth) {
  7776. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7777. if (!this._scrollLeft) {
  7778. this._scrollLeft = textLeft;
  7779. }
  7780. }
  7781. else {
  7782. this._scrollLeft = clipTextLeft;
  7783. }
  7784. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7785. // Cursor
  7786. if (this._isFocused) {
  7787. // Need to move cursor
  7788. if (this._clickedCoordinate) {
  7789. var rightPosition = this._scrollLeft + this._textWidth;
  7790. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7791. var currentSize = 0;
  7792. this._cursorOffset = 0;
  7793. var previousDist = 0;
  7794. do {
  7795. if (this._cursorOffset) {
  7796. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7797. }
  7798. this._cursorOffset++;
  7799. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7800. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7801. // Find closest move
  7802. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7803. this._cursorOffset--;
  7804. }
  7805. this._blinkIsEven = false;
  7806. this._clickedCoordinate = null;
  7807. }
  7808. // Render cursor
  7809. if (!this._blinkIsEven) {
  7810. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7811. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7812. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7813. if (cursorLeft < clipTextLeft) {
  7814. this._scrollLeft += (clipTextLeft - cursorLeft);
  7815. cursorLeft = clipTextLeft;
  7816. this._markAsDirty();
  7817. }
  7818. else if (cursorLeft > clipTextLeft + availableWidth) {
  7819. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7820. cursorLeft = clipTextLeft + availableWidth;
  7821. this._markAsDirty();
  7822. }
  7823. if (!this._isTextHighlightOn) {
  7824. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7825. }
  7826. }
  7827. clearTimeout(this._blinkTimeout);
  7828. this._blinkTimeout = setTimeout(function () {
  7829. _this._blinkIsEven = !_this._blinkIsEven;
  7830. _this._markAsDirty();
  7831. }, 500);
  7832. //show the highlighted text
  7833. if (this._isTextHighlightOn) {
  7834. clearTimeout(this._blinkTimeout);
  7835. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7836. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7837. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7838. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7839. if (highlightCursorLeft < clipTextLeft) {
  7840. width = width - (clipTextLeft - highlightCursorLeft);
  7841. if (!width) {
  7842. // when using left arrow on text.length > availableWidth;
  7843. // assigns the width of the first letter after clipTextLeft
  7844. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7845. }
  7846. highlightCursorLeft = clipTextLeft;
  7847. }
  7848. //for transparancy
  7849. context.globalAlpha = this._highligherOpacity;
  7850. context.fillStyle = this._textHighlightColor;
  7851. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7852. context.globalAlpha = 1.0;
  7853. }
  7854. }
  7855. context.restore();
  7856. // Border
  7857. if (this._thickness) {
  7858. if (this._isFocused) {
  7859. if (this.focusedColor) {
  7860. context.strokeStyle = this.focusedColor;
  7861. }
  7862. }
  7863. else {
  7864. if (this.color) {
  7865. context.strokeStyle = this.color;
  7866. }
  7867. }
  7868. context.lineWidth = this._thickness;
  7869. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7870. }
  7871. context.restore();
  7872. };
  7873. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7874. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7875. return false;
  7876. }
  7877. this._clickedCoordinate = coordinates.x;
  7878. this._isTextHighlightOn = false;
  7879. this._highlightedText = "";
  7880. this._cursorIndex = -1;
  7881. this._isPointerDown = true;
  7882. this._host._capturingControl[pointerId] = this;
  7883. if (this._host.focusedControl === this) {
  7884. // Move cursor
  7885. clearTimeout(this._blinkTimeout);
  7886. this._markAsDirty();
  7887. return true;
  7888. }
  7889. if (!this._isEnabled) {
  7890. return false;
  7891. }
  7892. this._host.focusedControl = this;
  7893. return true;
  7894. };
  7895. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7896. if (this._host.focusedControl === this && this._isPointerDown) {
  7897. this._clickedCoordinate = coordinates.x;
  7898. this._markAsDirty();
  7899. this._updateValueFromCursorIndex(this._cursorOffset);
  7900. }
  7901. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7902. };
  7903. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7904. this._isPointerDown = false;
  7905. delete this._host._capturingControl[pointerId];
  7906. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7907. };
  7908. InputText.prototype._beforeRenderText = function (text) {
  7909. return text;
  7910. };
  7911. InputText.prototype.dispose = function () {
  7912. _super.prototype.dispose.call(this);
  7913. this.onBlurObservable.clear();
  7914. this.onFocusObservable.clear();
  7915. this.onTextChangedObservable.clear();
  7916. this.onTextCopyObservable.clear();
  7917. this.onTextCutObservable.clear();
  7918. this.onTextPasteObservable.clear();
  7919. this.onTextHighlightObservable.clear();
  7920. this.onKeyboardEventProcessedObservable.clear();
  7921. };
  7922. return InputText;
  7923. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7924. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7925. /***/ }),
  7926. /***/ "./2D/controls/line.ts":
  7927. /*!*****************************!*\
  7928. !*** ./2D/controls/line.ts ***!
  7929. \*****************************/
  7930. /*! exports provided: Line */
  7931. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7932. "use strict";
  7933. __webpack_require__.r(__webpack_exports__);
  7934. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7935. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7936. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7937. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7938. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7939. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7940. /** Class used to render 2D lines */
  7941. var Line = /** @class */ (function (_super) {
  7942. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7943. /**
  7944. * Creates a new Line
  7945. * @param name defines the control name
  7946. */
  7947. function Line(name) {
  7948. var _this = _super.call(this, name) || this;
  7949. _this.name = name;
  7950. _this._lineWidth = 1;
  7951. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7952. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7953. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7954. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7955. _this._dash = new Array();
  7956. _this.isHitTestVisible = false;
  7957. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7958. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7959. return _this;
  7960. }
  7961. Object.defineProperty(Line.prototype, "dash", {
  7962. /** Gets or sets the dash pattern */
  7963. get: function () {
  7964. return this._dash;
  7965. },
  7966. set: function (value) {
  7967. if (this._dash === value) {
  7968. return;
  7969. }
  7970. this._dash = value;
  7971. this._markAsDirty();
  7972. },
  7973. enumerable: true,
  7974. configurable: true
  7975. });
  7976. Object.defineProperty(Line.prototype, "connectedControl", {
  7977. /** Gets or sets the control connected with the line end */
  7978. get: function () {
  7979. return this._connectedControl;
  7980. },
  7981. set: function (value) {
  7982. var _this = this;
  7983. if (this._connectedControl === value) {
  7984. return;
  7985. }
  7986. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7987. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7988. this._connectedControlDirtyObserver = null;
  7989. }
  7990. if (value) {
  7991. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7992. }
  7993. this._connectedControl = value;
  7994. this._markAsDirty();
  7995. },
  7996. enumerable: true,
  7997. configurable: true
  7998. });
  7999. Object.defineProperty(Line.prototype, "x1", {
  8000. /** Gets or sets start coordinates on X axis */
  8001. get: function () {
  8002. return this._x1.toString(this._host);
  8003. },
  8004. set: function (value) {
  8005. if (this._x1.toString(this._host) === value) {
  8006. return;
  8007. }
  8008. if (this._x1.fromString(value)) {
  8009. this._markAsDirty();
  8010. }
  8011. },
  8012. enumerable: true,
  8013. configurable: true
  8014. });
  8015. Object.defineProperty(Line.prototype, "y1", {
  8016. /** Gets or sets start coordinates on Y axis */
  8017. get: function () {
  8018. return this._y1.toString(this._host);
  8019. },
  8020. set: function (value) {
  8021. if (this._y1.toString(this._host) === value) {
  8022. return;
  8023. }
  8024. if (this._y1.fromString(value)) {
  8025. this._markAsDirty();
  8026. }
  8027. },
  8028. enumerable: true,
  8029. configurable: true
  8030. });
  8031. Object.defineProperty(Line.prototype, "x2", {
  8032. /** Gets or sets end coordinates on X axis */
  8033. get: function () {
  8034. return this._x2.toString(this._host);
  8035. },
  8036. set: function (value) {
  8037. if (this._x2.toString(this._host) === value) {
  8038. return;
  8039. }
  8040. if (this._x2.fromString(value)) {
  8041. this._markAsDirty();
  8042. }
  8043. },
  8044. enumerable: true,
  8045. configurable: true
  8046. });
  8047. Object.defineProperty(Line.prototype, "y2", {
  8048. /** Gets or sets end coordinates on Y axis */
  8049. get: function () {
  8050. return this._y2.toString(this._host);
  8051. },
  8052. set: function (value) {
  8053. if (this._y2.toString(this._host) === value) {
  8054. return;
  8055. }
  8056. if (this._y2.fromString(value)) {
  8057. this._markAsDirty();
  8058. }
  8059. },
  8060. enumerable: true,
  8061. configurable: true
  8062. });
  8063. Object.defineProperty(Line.prototype, "lineWidth", {
  8064. /** Gets or sets line width */
  8065. get: function () {
  8066. return this._lineWidth;
  8067. },
  8068. set: function (value) {
  8069. if (this._lineWidth === value) {
  8070. return;
  8071. }
  8072. this._lineWidth = value;
  8073. this._markAsDirty();
  8074. },
  8075. enumerable: true,
  8076. configurable: true
  8077. });
  8078. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8079. /** Gets or sets horizontal alignment */
  8080. set: function (value) {
  8081. return;
  8082. },
  8083. enumerable: true,
  8084. configurable: true
  8085. });
  8086. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8087. /** Gets or sets vertical alignment */
  8088. set: function (value) {
  8089. return;
  8090. },
  8091. enumerable: true,
  8092. configurable: true
  8093. });
  8094. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8095. get: function () {
  8096. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8097. },
  8098. enumerable: true,
  8099. configurable: true
  8100. });
  8101. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8102. get: function () {
  8103. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8104. },
  8105. enumerable: true,
  8106. configurable: true
  8107. });
  8108. Line.prototype._getTypeName = function () {
  8109. return "Line";
  8110. };
  8111. Line.prototype._draw = function (context) {
  8112. context.save();
  8113. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8114. context.shadowColor = this.shadowColor;
  8115. context.shadowBlur = this.shadowBlur;
  8116. context.shadowOffsetX = this.shadowOffsetX;
  8117. context.shadowOffsetY = this.shadowOffsetY;
  8118. }
  8119. this._applyStates(context);
  8120. context.strokeStyle = this.color;
  8121. context.lineWidth = this._lineWidth;
  8122. context.setLineDash(this._dash);
  8123. context.beginPath();
  8124. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8125. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8126. context.stroke();
  8127. context.restore();
  8128. };
  8129. Line.prototype._measure = function () {
  8130. // Width / Height
  8131. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8132. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8133. };
  8134. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8135. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8136. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8137. };
  8138. /**
  8139. * Move one end of the line given 3D cartesian coordinates.
  8140. * @param position Targeted world position
  8141. * @param scene Scene
  8142. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8143. */
  8144. Line.prototype.moveToVector3 = function (position, scene, end) {
  8145. if (end === void 0) { end = false; }
  8146. if (!this._host || this.parent !== this._host._rootContainer) {
  8147. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8148. return;
  8149. }
  8150. var globalViewport = this._host._getGlobalViewport(scene);
  8151. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8152. this._moveToProjectedPosition(projectedPosition, end);
  8153. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8154. this.notRenderable = true;
  8155. return;
  8156. }
  8157. this.notRenderable = false;
  8158. };
  8159. /**
  8160. * Move one end of the line to a position in screen absolute space.
  8161. * @param projectedPosition Position in screen absolute space (X, Y)
  8162. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8163. */
  8164. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8165. if (end === void 0) { end = false; }
  8166. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8167. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8168. if (end) {
  8169. this.x2 = x;
  8170. this.y2 = y;
  8171. this._x2.ignoreAdaptiveScaling = true;
  8172. this._y2.ignoreAdaptiveScaling = true;
  8173. }
  8174. else {
  8175. this.x1 = x;
  8176. this.y1 = y;
  8177. this._x1.ignoreAdaptiveScaling = true;
  8178. this._y1.ignoreAdaptiveScaling = true;
  8179. }
  8180. };
  8181. return Line;
  8182. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8183. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8184. /***/ }),
  8185. /***/ "./2D/controls/multiLine.ts":
  8186. /*!**********************************!*\
  8187. !*** ./2D/controls/multiLine.ts ***!
  8188. \**********************************/
  8189. /*! exports provided: MultiLine */
  8190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8191. "use strict";
  8192. __webpack_require__.r(__webpack_exports__);
  8193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8195. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8196. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8197. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8198. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8199. /**
  8200. * Class used to create multi line control
  8201. */
  8202. var MultiLine = /** @class */ (function (_super) {
  8203. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8204. /**
  8205. * Creates a new MultiLine
  8206. * @param name defines the control name
  8207. */
  8208. function MultiLine(name) {
  8209. var _this = _super.call(this, name) || this;
  8210. _this.name = name;
  8211. _this._lineWidth = 1;
  8212. /** Function called when a point is updated */
  8213. _this.onPointUpdate = function () {
  8214. _this._markAsDirty();
  8215. };
  8216. _this.isHitTestVisible = false;
  8217. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8218. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8219. _this._dash = [];
  8220. _this._points = [];
  8221. return _this;
  8222. }
  8223. Object.defineProperty(MultiLine.prototype, "dash", {
  8224. /** Gets or sets dash pattern */
  8225. get: function () {
  8226. return this._dash;
  8227. },
  8228. set: function (value) {
  8229. if (this._dash === value) {
  8230. return;
  8231. }
  8232. this._dash = value;
  8233. this._markAsDirty();
  8234. },
  8235. enumerable: true,
  8236. configurable: true
  8237. });
  8238. /**
  8239. * Gets point stored at specified index
  8240. * @param index defines the index to look for
  8241. * @returns the requested point if found
  8242. */
  8243. MultiLine.prototype.getAt = function (index) {
  8244. if (!this._points[index]) {
  8245. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8246. }
  8247. return this._points[index];
  8248. };
  8249. /**
  8250. * Adds new points to the point collection
  8251. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8252. * @returns the list of created MultiLinePoint
  8253. */
  8254. MultiLine.prototype.add = function () {
  8255. var _this = this;
  8256. var items = [];
  8257. for (var _i = 0; _i < arguments.length; _i++) {
  8258. items[_i] = arguments[_i];
  8259. }
  8260. return items.map(function (item) { return _this.push(item); });
  8261. };
  8262. /**
  8263. * Adds a new point to the point collection
  8264. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8265. * @returns the created MultiLinePoint
  8266. */
  8267. MultiLine.prototype.push = function (item) {
  8268. var point = this.getAt(this._points.length);
  8269. if (item == null) {
  8270. return point;
  8271. }
  8272. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8273. point.mesh = item;
  8274. }
  8275. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8276. point.control = item;
  8277. }
  8278. else if (item.x != null && item.y != null) {
  8279. point.x = item.x;
  8280. point.y = item.y;
  8281. }
  8282. return point;
  8283. };
  8284. /**
  8285. * Remove a specific value or point from the active point collection
  8286. * @param value defines the value or point to remove
  8287. */
  8288. MultiLine.prototype.remove = function (value) {
  8289. var index;
  8290. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8291. index = this._points.indexOf(value);
  8292. if (index === -1) {
  8293. return;
  8294. }
  8295. }
  8296. else {
  8297. index = value;
  8298. }
  8299. var point = this._points[index];
  8300. if (!point) {
  8301. return;
  8302. }
  8303. point.dispose();
  8304. this._points.splice(index, 1);
  8305. };
  8306. /**
  8307. * Resets this object to initial state (no point)
  8308. */
  8309. MultiLine.prototype.reset = function () {
  8310. while (this._points.length > 0) {
  8311. this.remove(this._points.length - 1);
  8312. }
  8313. };
  8314. /**
  8315. * Resets all links
  8316. */
  8317. MultiLine.prototype.resetLinks = function () {
  8318. this._points.forEach(function (point) {
  8319. if (point != null) {
  8320. point.resetLinks();
  8321. }
  8322. });
  8323. };
  8324. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8325. /** Gets or sets line width */
  8326. get: function () {
  8327. return this._lineWidth;
  8328. },
  8329. set: function (value) {
  8330. if (this._lineWidth === value) {
  8331. return;
  8332. }
  8333. this._lineWidth = value;
  8334. this._markAsDirty();
  8335. },
  8336. enumerable: true,
  8337. configurable: true
  8338. });
  8339. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8340. set: function (value) {
  8341. return;
  8342. },
  8343. enumerable: true,
  8344. configurable: true
  8345. });
  8346. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8347. set: function (value) {
  8348. return;
  8349. },
  8350. enumerable: true,
  8351. configurable: true
  8352. });
  8353. MultiLine.prototype._getTypeName = function () {
  8354. return "MultiLine";
  8355. };
  8356. MultiLine.prototype._draw = function (context) {
  8357. context.save();
  8358. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8359. context.shadowColor = this.shadowColor;
  8360. context.shadowBlur = this.shadowBlur;
  8361. context.shadowOffsetX = this.shadowOffsetX;
  8362. context.shadowOffsetY = this.shadowOffsetY;
  8363. }
  8364. this._applyStates(context);
  8365. context.strokeStyle = this.color;
  8366. context.lineWidth = this._lineWidth;
  8367. context.setLineDash(this._dash);
  8368. context.beginPath();
  8369. var first = true; //first index is not necessarily 0
  8370. this._points.forEach(function (point) {
  8371. if (!point) {
  8372. return;
  8373. }
  8374. if (first) {
  8375. context.moveTo(point._point.x, point._point.y);
  8376. first = false;
  8377. }
  8378. else {
  8379. context.lineTo(point._point.x, point._point.y);
  8380. }
  8381. });
  8382. context.stroke();
  8383. context.restore();
  8384. };
  8385. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8386. var _this = this;
  8387. this._minX = null;
  8388. this._minY = null;
  8389. this._maxX = null;
  8390. this._maxY = null;
  8391. this._points.forEach(function (point, index) {
  8392. if (!point) {
  8393. return;
  8394. }
  8395. point.translate();
  8396. if (_this._minX == null || point._point.x < _this._minX) {
  8397. _this._minX = point._point.x;
  8398. }
  8399. if (_this._minY == null || point._point.y < _this._minY) {
  8400. _this._minY = point._point.y;
  8401. }
  8402. if (_this._maxX == null || point._point.x > _this._maxX) {
  8403. _this._maxX = point._point.x;
  8404. }
  8405. if (_this._maxY == null || point._point.y > _this._maxY) {
  8406. _this._maxY = point._point.y;
  8407. }
  8408. });
  8409. if (this._minX == null) {
  8410. this._minX = 0;
  8411. }
  8412. if (this._minY == null) {
  8413. this._minY = 0;
  8414. }
  8415. if (this._maxX == null) {
  8416. this._maxX = 0;
  8417. }
  8418. if (this._maxY == null) {
  8419. this._maxY = 0;
  8420. }
  8421. };
  8422. MultiLine.prototype._measure = function () {
  8423. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8424. return;
  8425. }
  8426. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8427. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8428. };
  8429. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8430. if (this._minX == null || this._minY == null) {
  8431. return;
  8432. }
  8433. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8434. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8435. };
  8436. MultiLine.prototype.dispose = function () {
  8437. this.reset();
  8438. _super.prototype.dispose.call(this);
  8439. };
  8440. return MultiLine;
  8441. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8442. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8443. /***/ }),
  8444. /***/ "./2D/controls/radioButton.ts":
  8445. /*!************************************!*\
  8446. !*** ./2D/controls/radioButton.ts ***!
  8447. \************************************/
  8448. /*! exports provided: RadioButton */
  8449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8450. "use strict";
  8451. __webpack_require__.r(__webpack_exports__);
  8452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8453. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8454. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8455. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8456. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8457. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8458. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8459. /**
  8460. * Class used to create radio button controls
  8461. */
  8462. var RadioButton = /** @class */ (function (_super) {
  8463. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8464. /**
  8465. * Creates a new RadioButton
  8466. * @param name defines the control name
  8467. */
  8468. function RadioButton(name) {
  8469. var _this = _super.call(this, name) || this;
  8470. _this.name = name;
  8471. _this._isChecked = false;
  8472. _this._background = "black";
  8473. _this._checkSizeRatio = 0.8;
  8474. _this._thickness = 1;
  8475. /** Gets or sets group name */
  8476. _this.group = "";
  8477. /** Observable raised when isChecked is changed */
  8478. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8479. _this.isPointerBlocker = true;
  8480. return _this;
  8481. }
  8482. Object.defineProperty(RadioButton.prototype, "thickness", {
  8483. /** Gets or sets border thickness */
  8484. get: function () {
  8485. return this._thickness;
  8486. },
  8487. set: function (value) {
  8488. if (this._thickness === value) {
  8489. return;
  8490. }
  8491. this._thickness = value;
  8492. this._markAsDirty();
  8493. },
  8494. enumerable: true,
  8495. configurable: true
  8496. });
  8497. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8498. /** Gets or sets a value indicating the ratio between overall size and check size */
  8499. get: function () {
  8500. return this._checkSizeRatio;
  8501. },
  8502. set: function (value) {
  8503. value = Math.max(Math.min(1, value), 0);
  8504. if (this._checkSizeRatio === value) {
  8505. return;
  8506. }
  8507. this._checkSizeRatio = value;
  8508. this._markAsDirty();
  8509. },
  8510. enumerable: true,
  8511. configurable: true
  8512. });
  8513. Object.defineProperty(RadioButton.prototype, "background", {
  8514. /** Gets or sets background color */
  8515. get: function () {
  8516. return this._background;
  8517. },
  8518. set: function (value) {
  8519. if (this._background === value) {
  8520. return;
  8521. }
  8522. this._background = value;
  8523. this._markAsDirty();
  8524. },
  8525. enumerable: true,
  8526. configurable: true
  8527. });
  8528. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8529. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8530. get: function () {
  8531. return this._isChecked;
  8532. },
  8533. set: function (value) {
  8534. var _this = this;
  8535. if (this._isChecked === value) {
  8536. return;
  8537. }
  8538. this._isChecked = value;
  8539. this._markAsDirty();
  8540. this.onIsCheckedChangedObservable.notifyObservers(value);
  8541. if (this._isChecked && this._host) {
  8542. // Update all controls from same group
  8543. this._host.executeOnAllControls(function (control) {
  8544. if (control === _this) {
  8545. return;
  8546. }
  8547. if (control.group === undefined) {
  8548. return;
  8549. }
  8550. var childRadio = control;
  8551. if (childRadio.group === _this.group) {
  8552. childRadio.isChecked = false;
  8553. }
  8554. });
  8555. }
  8556. },
  8557. enumerable: true,
  8558. configurable: true
  8559. });
  8560. RadioButton.prototype._getTypeName = function () {
  8561. return "RadioButton";
  8562. };
  8563. RadioButton.prototype._draw = function (context) {
  8564. context.save();
  8565. this._applyStates(context);
  8566. var actualWidth = this._currentMeasure.width - this._thickness;
  8567. var actualHeight = this._currentMeasure.height - this._thickness;
  8568. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8569. context.shadowColor = this.shadowColor;
  8570. context.shadowBlur = this.shadowBlur;
  8571. context.shadowOffsetX = this.shadowOffsetX;
  8572. context.shadowOffsetY = this.shadowOffsetY;
  8573. }
  8574. // Outer
  8575. _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);
  8576. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8577. context.fill();
  8578. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8579. context.shadowBlur = 0;
  8580. context.shadowOffsetX = 0;
  8581. context.shadowOffsetY = 0;
  8582. }
  8583. context.strokeStyle = this.color;
  8584. context.lineWidth = this._thickness;
  8585. context.stroke();
  8586. // Inner
  8587. if (this._isChecked) {
  8588. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8589. var offsetWidth = actualWidth * this._checkSizeRatio;
  8590. var offseHeight = actualHeight * this._checkSizeRatio;
  8591. _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);
  8592. context.fill();
  8593. }
  8594. context.restore();
  8595. };
  8596. // Events
  8597. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8598. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8599. return false;
  8600. }
  8601. if (!this.isChecked) {
  8602. this.isChecked = true;
  8603. }
  8604. return true;
  8605. };
  8606. /**
  8607. * Utility function to easily create a radio button with a header
  8608. * @param title defines the label to use for the header
  8609. * @param group defines the group to use for the radio button
  8610. * @param isChecked defines the initial state of the radio button
  8611. * @param onValueChanged defines the callback to call when value changes
  8612. * @returns a StackPanel containing the radio button and a textBlock
  8613. */
  8614. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8615. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8616. panel.isVertical = false;
  8617. panel.height = "30px";
  8618. var radio = new RadioButton();
  8619. radio.width = "20px";
  8620. radio.height = "20px";
  8621. radio.isChecked = isChecked;
  8622. radio.color = "green";
  8623. radio.group = group;
  8624. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8625. panel.addControl(radio);
  8626. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8627. header.text = title;
  8628. header.width = "180px";
  8629. header.paddingLeft = "5px";
  8630. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8631. header.color = "white";
  8632. panel.addControl(header);
  8633. return panel;
  8634. };
  8635. return RadioButton;
  8636. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8637. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8638. /***/ }),
  8639. /***/ "./2D/controls/rectangle.ts":
  8640. /*!**********************************!*\
  8641. !*** ./2D/controls/rectangle.ts ***!
  8642. \**********************************/
  8643. /*! exports provided: Rectangle */
  8644. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8645. "use strict";
  8646. __webpack_require__.r(__webpack_exports__);
  8647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8648. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8649. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8650. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  8651. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8652. /** Class used to create rectangle container */
  8653. var Rectangle = /** @class */ (function (_super) {
  8654. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8655. /**
  8656. * Creates a new Rectangle
  8657. * @param name defines the control name
  8658. */
  8659. function Rectangle(name) {
  8660. var _this = _super.call(this, name) || this;
  8661. _this.name = name;
  8662. _this._thickness = 1;
  8663. _this._cornerRadius = 0;
  8664. return _this;
  8665. }
  8666. Object.defineProperty(Rectangle.prototype, "thickness", {
  8667. /** Gets or sets border thickness */
  8668. get: function () {
  8669. return this._thickness;
  8670. },
  8671. set: function (value) {
  8672. if (this._thickness === value) {
  8673. return;
  8674. }
  8675. this._thickness = value;
  8676. this._markAsDirty();
  8677. },
  8678. enumerable: true,
  8679. configurable: true
  8680. });
  8681. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8682. /** Gets or sets the corner radius angle */
  8683. get: function () {
  8684. return this._cornerRadius;
  8685. },
  8686. set: function (value) {
  8687. if (value < 0) {
  8688. value = 0;
  8689. }
  8690. if (this._cornerRadius === value) {
  8691. return;
  8692. }
  8693. this._cornerRadius = value;
  8694. this._markAsDirty();
  8695. },
  8696. enumerable: true,
  8697. configurable: true
  8698. });
  8699. Rectangle.prototype._getTypeName = function () {
  8700. return "Rectangle";
  8701. };
  8702. Rectangle.prototype._localDraw = function (context) {
  8703. context.save();
  8704. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8705. context.shadowColor = this.shadowColor;
  8706. context.shadowBlur = this.shadowBlur;
  8707. context.shadowOffsetX = this.shadowOffsetX;
  8708. context.shadowOffsetY = this.shadowOffsetY;
  8709. }
  8710. if (this._background) {
  8711. context.fillStyle = this._background;
  8712. if (this._cornerRadius) {
  8713. this._drawRoundedRect(context, this._thickness / 2);
  8714. context.fill();
  8715. }
  8716. else {
  8717. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8718. }
  8719. }
  8720. if (this._thickness) {
  8721. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8722. context.shadowBlur = 0;
  8723. context.shadowOffsetX = 0;
  8724. context.shadowOffsetY = 0;
  8725. }
  8726. if (this.color) {
  8727. context.strokeStyle = this.color;
  8728. }
  8729. context.lineWidth = this._thickness;
  8730. if (this._cornerRadius) {
  8731. this._drawRoundedRect(context, this._thickness / 2);
  8732. context.stroke();
  8733. }
  8734. else {
  8735. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8736. }
  8737. }
  8738. context.restore();
  8739. };
  8740. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8741. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8742. this._measureForChildren.width -= 2 * this._thickness;
  8743. this._measureForChildren.height -= 2 * this._thickness;
  8744. this._measureForChildren.left += this._thickness;
  8745. this._measureForChildren.top += this._thickness;
  8746. };
  8747. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8748. if (offset === void 0) { offset = 0; }
  8749. var x = this._currentMeasure.left + offset;
  8750. var y = this._currentMeasure.top + offset;
  8751. var width = this._currentMeasure.width - offset * 2;
  8752. var height = this._currentMeasure.height - offset * 2;
  8753. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8754. context.beginPath();
  8755. context.moveTo(x + radius, y);
  8756. context.lineTo(x + width - radius, y);
  8757. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8758. context.lineTo(x + width, y + height - radius);
  8759. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8760. context.lineTo(x + radius, y + height);
  8761. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8762. context.lineTo(x, y + radius);
  8763. context.quadraticCurveTo(x, y, x + radius, y);
  8764. context.closePath();
  8765. };
  8766. Rectangle.prototype._clipForChildren = function (context) {
  8767. if (this._cornerRadius) {
  8768. this._drawRoundedRect(context, this._thickness);
  8769. context.clip();
  8770. }
  8771. };
  8772. return Rectangle;
  8773. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8774. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8775. /***/ }),
  8776. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8777. /*!***************************************************!*\
  8778. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8779. \***************************************************/
  8780. /*! exports provided: ScrollViewer */
  8781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8782. "use strict";
  8783. __webpack_require__.r(__webpack_exports__);
  8784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8785. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8786. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8787. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8788. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8789. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8790. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8791. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8792. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8793. /**
  8794. * Class used to hold a viewer window and sliders in a grid
  8795. */
  8796. var ScrollViewer = /** @class */ (function (_super) {
  8797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8798. /**
  8799. * Creates a new ScrollViewer
  8800. * @param name of ScrollViewer
  8801. */
  8802. function ScrollViewer(name) {
  8803. var _this = _super.call(this, name) || this;
  8804. _this._barSize = 20;
  8805. _this._pointerIsOver = false;
  8806. _this._wheelPrecision = 0.05;
  8807. _this.onDirtyObservable.add(function () {
  8808. _this._horizontalBarSpace.color = _this.color;
  8809. _this._verticalBarSpace.color = _this.color;
  8810. _this._dragSpace.color = _this.color;
  8811. });
  8812. _this.onPointerEnterObservable.add(function () {
  8813. _this._pointerIsOver = true;
  8814. });
  8815. _this.onPointerOutObservable.add(function () {
  8816. _this._pointerIsOver = false;
  8817. });
  8818. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8819. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8820. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8821. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8822. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8823. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8824. _this._grid.addColumnDefinition(1);
  8825. _this._grid.addColumnDefinition(0, true);
  8826. _this._grid.addRowDefinition(1);
  8827. _this._grid.addRowDefinition(0, true);
  8828. _super.prototype.addControl.call(_this, _this._grid);
  8829. _this._grid.addControl(_this._window, 0, 0);
  8830. _this._verticalBar.paddingLeft = 0;
  8831. _this._verticalBar.width = "100%";
  8832. _this._verticalBar.height = "100%";
  8833. _this._verticalBar.barOffset = 0;
  8834. _this._verticalBar.value = 0;
  8835. _this._verticalBar.maximum = 1;
  8836. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8837. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8838. _this._verticalBar.isVertical = true;
  8839. _this._verticalBar.rotation = Math.PI;
  8840. _this._verticalBar.isVisible = false;
  8841. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8842. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8843. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8844. _this._verticalBarSpace.thickness = 1;
  8845. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8846. _this._verticalBarSpace.addControl(_this._verticalBar);
  8847. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8848. _this._window.top = value * _this._endTop + "px";
  8849. });
  8850. _this._horizontalBar.paddingLeft = 0;
  8851. _this._horizontalBar.width = "100%";
  8852. _this._horizontalBar.height = "100%";
  8853. _this._horizontalBar.barOffset = 0;
  8854. _this._horizontalBar.value = 0;
  8855. _this._horizontalBar.maximum = 1;
  8856. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8857. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8858. _this._horizontalBar.isVisible = false;
  8859. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8860. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8861. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8862. _this._horizontalBarSpace.thickness = 1;
  8863. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8864. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8865. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8866. _this._window.left = value * _this._endLeft + "px";
  8867. });
  8868. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8869. _this._dragSpace.thickness = 1;
  8870. _this._grid.addControl(_this._dragSpace, 1, 1);
  8871. // Colors
  8872. _this.barColor = "grey";
  8873. _this.barBackground = "transparent";
  8874. return _this;
  8875. }
  8876. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8877. /**
  8878. * Gets the horizontal scrollbar
  8879. */
  8880. get: function () {
  8881. return this._horizontalBar;
  8882. },
  8883. enumerable: true,
  8884. configurable: true
  8885. });
  8886. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8887. /**
  8888. * Gets the vertical scrollbar
  8889. */
  8890. get: function () {
  8891. return this._verticalBar;
  8892. },
  8893. enumerable: true,
  8894. configurable: true
  8895. });
  8896. /**
  8897. * Adds a new control to the current container
  8898. * @param control defines the control to add
  8899. * @returns the current container
  8900. */
  8901. ScrollViewer.prototype.addControl = function (control) {
  8902. if (!control) {
  8903. return this;
  8904. }
  8905. this._window.addControl(control);
  8906. return this;
  8907. };
  8908. /**
  8909. * Removes a control from the current container
  8910. * @param control defines the control to remove
  8911. * @returns the current container
  8912. */
  8913. ScrollViewer.prototype.removeControl = function (control) {
  8914. this._window.removeControl(control);
  8915. return this;
  8916. };
  8917. Object.defineProperty(ScrollViewer.prototype, "children", {
  8918. /** Gets the list of children */
  8919. get: function () {
  8920. return this._window.children;
  8921. },
  8922. enumerable: true,
  8923. configurable: true
  8924. });
  8925. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8926. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8927. var child = _a[_i];
  8928. child._markMatrixAsDirty();
  8929. }
  8930. };
  8931. /** Reset the scroll viewer window to initial size */
  8932. ScrollViewer.prototype.resetWindow = function () {
  8933. this._window.width = "100%";
  8934. this._window.height = "100%";
  8935. };
  8936. ScrollViewer.prototype._getTypeName = function () {
  8937. return "ScrollViewer";
  8938. };
  8939. ScrollViewer.prototype._buildClientSizes = function () {
  8940. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8941. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8942. this._clientWidth = this._window.parentClientWidth;
  8943. this._clientHeight = this._window.parentClientHeight;
  8944. };
  8945. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8946. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8947. this._buildClientSizes();
  8948. };
  8949. ScrollViewer.prototype._postMeasure = function () {
  8950. _super.prototype._postMeasure.call(this);
  8951. this._updateScroller();
  8952. };
  8953. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8954. /**
  8955. * Gets or sets the mouse wheel precision
  8956. * from 0 to 1 with a default value of 0.05
  8957. * */
  8958. get: function () {
  8959. return this._wheelPrecision;
  8960. },
  8961. set: function (value) {
  8962. if (this._wheelPrecision === value) {
  8963. return;
  8964. }
  8965. if (value < 0) {
  8966. value = 0;
  8967. }
  8968. if (value > 1) {
  8969. value = 1;
  8970. }
  8971. this._wheelPrecision = value;
  8972. },
  8973. enumerable: true,
  8974. configurable: true
  8975. });
  8976. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8977. /** Gets or sets the bar color */
  8978. get: function () {
  8979. return this._barColor;
  8980. },
  8981. set: function (color) {
  8982. if (this._barColor === color) {
  8983. return;
  8984. }
  8985. this._barColor = color;
  8986. this._horizontalBar.color = color;
  8987. this._verticalBar.color = color;
  8988. },
  8989. enumerable: true,
  8990. configurable: true
  8991. });
  8992. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8993. /** Gets or sets the size of the bar */
  8994. get: function () {
  8995. return this._barSize;
  8996. },
  8997. set: function (value) {
  8998. if (this._barSize === value) {
  8999. return;
  9000. }
  9001. this._barSize = value;
  9002. this._markAsDirty();
  9003. if (this._horizontalBar.isVisible) {
  9004. this._grid.setRowDefinition(1, this._barSize, true);
  9005. }
  9006. if (this._verticalBar.isVisible) {
  9007. this._grid.setColumnDefinition(1, this._barSize, true);
  9008. }
  9009. },
  9010. enumerable: true,
  9011. configurable: true
  9012. });
  9013. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9014. /** Gets or sets the bar background */
  9015. get: function () {
  9016. return this._barBackground;
  9017. },
  9018. set: function (color) {
  9019. if (this._barBackground === color) {
  9020. return;
  9021. }
  9022. this._barBackground = color;
  9023. this._horizontalBar.background = color;
  9024. this._verticalBar.background = color;
  9025. this._dragSpace.background = color;
  9026. },
  9027. enumerable: true,
  9028. configurable: true
  9029. });
  9030. /** @hidden */
  9031. ScrollViewer.prototype._updateScroller = function () {
  9032. var windowContentsWidth = this._window._currentMeasure.width;
  9033. var windowContentsHeight = this._window._currentMeasure.height;
  9034. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9035. this._grid.setRowDefinition(1, 0, true);
  9036. this._horizontalBar.isVisible = false;
  9037. this._horizontalBar.value = 0;
  9038. this._rebuildLayout = true;
  9039. }
  9040. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9041. this._grid.setRowDefinition(1, this._barSize, true);
  9042. this._horizontalBar.isVisible = true;
  9043. this._rebuildLayout = true;
  9044. }
  9045. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9046. this._grid.setColumnDefinition(1, 0, true);
  9047. this._verticalBar.isVisible = false;
  9048. this._verticalBar.value = 0;
  9049. this._rebuildLayout = true;
  9050. }
  9051. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9052. this._grid.setColumnDefinition(1, this._barSize, true);
  9053. this._verticalBar.isVisible = true;
  9054. this._rebuildLayout = true;
  9055. }
  9056. this._buildClientSizes();
  9057. this._endLeft = this._clientWidth - windowContentsWidth;
  9058. this._endTop = this._clientHeight - windowContentsHeight;
  9059. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9060. var newTop = this._verticalBar.value * this._endTop + "px";
  9061. if (newLeft !== this._window.left) {
  9062. this._window.left = newLeft;
  9063. this._rebuildLayout = true;
  9064. }
  9065. if (newTop !== this._window.top) {
  9066. this._window.top = newTop;
  9067. this._rebuildLayout = true;
  9068. }
  9069. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  9070. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  9071. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  9072. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  9073. };
  9074. ScrollViewer.prototype._link = function (host) {
  9075. _super.prototype._link.call(this, host);
  9076. this._attachWheel();
  9077. };
  9078. /** @hidden */
  9079. ScrollViewer.prototype._attachWheel = function () {
  9080. var _this = this;
  9081. if (!this._host || this._onPointerObserver) {
  9082. return;
  9083. }
  9084. var scene = this._host.getScene();
  9085. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9086. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9087. return;
  9088. }
  9089. if (_this._verticalBar.isVisible == true) {
  9090. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9091. _this._verticalBar.value -= _this._wheelPrecision;
  9092. }
  9093. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9094. _this._verticalBar.value += _this._wheelPrecision;
  9095. }
  9096. }
  9097. if (_this._horizontalBar.isVisible == true) {
  9098. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9099. _this._horizontalBar.value += _this._wheelPrecision;
  9100. }
  9101. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9102. _this._horizontalBar.value -= _this._wheelPrecision;
  9103. }
  9104. }
  9105. });
  9106. };
  9107. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9108. if (!this.isHighlighted) {
  9109. return;
  9110. }
  9111. _super.prototype._renderHighlightSpecific.call(this, context);
  9112. this._grid._renderHighlightSpecific(context);
  9113. context.restore();
  9114. };
  9115. /** Releases associated resources */
  9116. ScrollViewer.prototype.dispose = function () {
  9117. var scene = this._host.getScene();
  9118. if (scene && this._onPointerObserver) {
  9119. scene.onPointerObservable.remove(this._onPointerObserver);
  9120. this._onPointerObserver = null;
  9121. }
  9122. _super.prototype.dispose.call(this);
  9123. };
  9124. return ScrollViewer;
  9125. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9126. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9127. /***/ }),
  9128. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9129. /*!*********************************************************!*\
  9130. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9131. \*********************************************************/
  9132. /*! exports provided: _ScrollViewerWindow */
  9133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9134. "use strict";
  9135. __webpack_require__.r(__webpack_exports__);
  9136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9137. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9138. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9139. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9140. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9141. /**
  9142. * Class used to hold a the container for ScrollViewer
  9143. * @hidden
  9144. */
  9145. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9147. /**
  9148. * Creates a new ScrollViewerWindow
  9149. * @param name of ScrollViewerWindow
  9150. */
  9151. function _ScrollViewerWindow(name) {
  9152. return _super.call(this, name) || this;
  9153. }
  9154. _ScrollViewerWindow.prototype._getTypeName = function () {
  9155. return "ScrollViewerWindow";
  9156. };
  9157. /** @hidden */
  9158. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9159. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9160. this._measureForChildren.left = this._currentMeasure.left;
  9161. this._measureForChildren.top = this._currentMeasure.top;
  9162. this._measureForChildren.width = parentMeasure.width;
  9163. this._measureForChildren.height = parentMeasure.height;
  9164. };
  9165. _ScrollViewerWindow.prototype._postMeasure = function () {
  9166. var maxWidth = this.parentClientWidth;
  9167. var maxHeight = this.parentClientHeight;
  9168. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9169. var child = _a[_i];
  9170. if (!child.isVisible || child.notRenderable) {
  9171. continue;
  9172. }
  9173. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9174. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9175. }
  9176. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9177. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9178. }
  9179. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9180. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9181. }
  9182. if (this._currentMeasure.width !== maxWidth) {
  9183. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9184. this._currentMeasure.width = maxWidth;
  9185. this._rebuildLayout = true;
  9186. this._isDirty = true;
  9187. }
  9188. if (this._currentMeasure.height !== maxHeight) {
  9189. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9190. this._currentMeasure.height = maxHeight;
  9191. this._rebuildLayout = true;
  9192. this._isDirty = true;
  9193. }
  9194. _super.prototype._postMeasure.call(this);
  9195. };
  9196. return _ScrollViewerWindow;
  9197. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9198. /***/ }),
  9199. /***/ "./2D/controls/selector.ts":
  9200. /*!*********************************!*\
  9201. !*** ./2D/controls/selector.ts ***!
  9202. \*********************************/
  9203. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9205. "use strict";
  9206. __webpack_require__.r(__webpack_exports__);
  9207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9212. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9213. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9214. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9215. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9216. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9217. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9218. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9219. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9220. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9221. /** Class used to create a RadioGroup
  9222. * which contains groups of radio buttons
  9223. */
  9224. var SelectorGroup = /** @class */ (function () {
  9225. /**
  9226. * Creates a new SelectorGroup
  9227. * @param name of group, used as a group heading
  9228. */
  9229. function SelectorGroup(
  9230. /** name of SelectorGroup */
  9231. name) {
  9232. this.name = name;
  9233. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9234. this._selectors = new Array();
  9235. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9236. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9237. this._groupHeader = this._addGroupHeader(name);
  9238. }
  9239. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9240. /** Gets the groupPanel of the SelectorGroup */
  9241. get: function () {
  9242. return this._groupPanel;
  9243. },
  9244. enumerable: true,
  9245. configurable: true
  9246. });
  9247. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9248. /** Gets the selectors array */
  9249. get: function () {
  9250. return this._selectors;
  9251. },
  9252. enumerable: true,
  9253. configurable: true
  9254. });
  9255. Object.defineProperty(SelectorGroup.prototype, "header", {
  9256. /** Gets and sets the group header */
  9257. get: function () {
  9258. return this._groupHeader.text;
  9259. },
  9260. set: function (label) {
  9261. if (this._groupHeader.text === "label") {
  9262. return;
  9263. }
  9264. this._groupHeader.text = label;
  9265. },
  9266. enumerable: true,
  9267. configurable: true
  9268. });
  9269. /** @hidden */
  9270. SelectorGroup.prototype._addGroupHeader = function (text) {
  9271. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9272. groupHeading.width = 0.9;
  9273. groupHeading.height = "30px";
  9274. groupHeading.textWrapping = true;
  9275. groupHeading.color = "black";
  9276. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9277. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9278. groupHeading.left = "2px";
  9279. this._groupPanel.addControl(groupHeading);
  9280. return groupHeading;
  9281. };
  9282. /** @hidden*/
  9283. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9284. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9285. return;
  9286. }
  9287. return this._selectors[selectorNb];
  9288. };
  9289. /** Removes the selector at the given position
  9290. * @param selectorNb the position of the selector within the group
  9291. */
  9292. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9293. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9294. return;
  9295. }
  9296. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9297. this._selectors.splice(selectorNb, 1);
  9298. };
  9299. return SelectorGroup;
  9300. }());
  9301. /** Class used to create a CheckboxGroup
  9302. * which contains groups of checkbox buttons
  9303. */
  9304. var CheckboxGroup = /** @class */ (function (_super) {
  9305. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9306. function CheckboxGroup() {
  9307. return _super !== null && _super.apply(this, arguments) || this;
  9308. }
  9309. /** Adds a checkbox as a control
  9310. * @param text is the label for the selector
  9311. * @param func is the function called when the Selector is checked
  9312. * @param checked is true when Selector is checked
  9313. */
  9314. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9315. if (func === void 0) { func = function (s) { }; }
  9316. if (checked === void 0) { checked = false; }
  9317. var checked = checked || false;
  9318. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9319. button.width = "20px";
  9320. button.height = "20px";
  9321. button.color = "#364249";
  9322. button.background = "#CCCCCC";
  9323. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9324. button.onIsCheckedChangedObservable.add(function (state) {
  9325. func(state);
  9326. });
  9327. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9328. _selector.height = "30px";
  9329. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9330. _selector.left = "4px";
  9331. this.groupPanel.addControl(_selector);
  9332. this.selectors.push(_selector);
  9333. button.isChecked = checked;
  9334. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9335. button.color = this.groupPanel.parent.parent.buttonColor;
  9336. button.background = this.groupPanel.parent.parent.buttonBackground;
  9337. }
  9338. };
  9339. /** @hidden */
  9340. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9341. this.selectors[selectorNb].children[1].text = label;
  9342. };
  9343. /** @hidden */
  9344. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9345. this.selectors[selectorNb].children[1].color = color;
  9346. };
  9347. /** @hidden */
  9348. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9349. this.selectors[selectorNb].children[0].color = color;
  9350. };
  9351. /** @hidden */
  9352. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9353. this.selectors[selectorNb].children[0].background = color;
  9354. };
  9355. return CheckboxGroup;
  9356. }(SelectorGroup));
  9357. /** Class used to create a RadioGroup
  9358. * which contains groups of radio buttons
  9359. */
  9360. var RadioGroup = /** @class */ (function (_super) {
  9361. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9362. function RadioGroup() {
  9363. var _this = _super !== null && _super.apply(this, arguments) || this;
  9364. _this._selectNb = 0;
  9365. return _this;
  9366. }
  9367. /** Adds a radio button as a control
  9368. * @param label is the label for the selector
  9369. * @param func is the function called when the Selector is checked
  9370. * @param checked is true when Selector is checked
  9371. */
  9372. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9373. if (func === void 0) { func = function (n) { }; }
  9374. if (checked === void 0) { checked = false; }
  9375. var nb = this._selectNb++;
  9376. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9377. button.name = label;
  9378. button.width = "20px";
  9379. button.height = "20px";
  9380. button.color = "#364249";
  9381. button.background = "#CCCCCC";
  9382. button.group = this.name;
  9383. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9384. button.onIsCheckedChangedObservable.add(function (state) {
  9385. if (state) {
  9386. func(nb);
  9387. }
  9388. });
  9389. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9390. _selector.height = "30px";
  9391. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9392. _selector.left = "4px";
  9393. this.groupPanel.addControl(_selector);
  9394. this.selectors.push(_selector);
  9395. button.isChecked = checked;
  9396. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9397. button.color = this.groupPanel.parent.parent.buttonColor;
  9398. button.background = this.groupPanel.parent.parent.buttonBackground;
  9399. }
  9400. };
  9401. /** @hidden */
  9402. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9403. this.selectors[selectorNb].children[1].text = label;
  9404. };
  9405. /** @hidden */
  9406. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9407. this.selectors[selectorNb].children[1].color = color;
  9408. };
  9409. /** @hidden */
  9410. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9411. this.selectors[selectorNb].children[0].color = color;
  9412. };
  9413. /** @hidden */
  9414. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9415. this.selectors[selectorNb].children[0].background = color;
  9416. };
  9417. return RadioGroup;
  9418. }(SelectorGroup));
  9419. /** Class used to create a SliderGroup
  9420. * which contains groups of slider buttons
  9421. */
  9422. var SliderGroup = /** @class */ (function (_super) {
  9423. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9424. function SliderGroup() {
  9425. return _super !== null && _super.apply(this, arguments) || this;
  9426. }
  9427. /**
  9428. * Adds a slider to the SelectorGroup
  9429. * @param label is the label for the SliderBar
  9430. * @param func is the function called when the Slider moves
  9431. * @param unit is a string describing the units used, eg degrees or metres
  9432. * @param min is the minimum value for the Slider
  9433. * @param max is the maximum value for the Slider
  9434. * @param value is the start value for the Slider between min and max
  9435. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9436. */
  9437. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9438. if (func === void 0) { func = function (v) { }; }
  9439. if (unit === void 0) { unit = "Units"; }
  9440. if (min === void 0) { min = 0; }
  9441. if (max === void 0) { max = 0; }
  9442. if (value === void 0) { value = 0; }
  9443. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9444. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9445. button.name = unit;
  9446. button.value = value;
  9447. button.minimum = min;
  9448. button.maximum = max;
  9449. button.width = 0.9;
  9450. button.height = "20px";
  9451. button.color = "#364249";
  9452. button.background = "#CCCCCC";
  9453. button.borderColor = "black";
  9454. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9455. button.left = "4px";
  9456. button.paddingBottom = "4px";
  9457. button.onValueChangedObservable.add(function (value) {
  9458. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9459. func(value);
  9460. });
  9461. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9462. _selector.height = "60px";
  9463. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9464. _selector.left = "4px";
  9465. _selector.children[0].name = label;
  9466. this.groupPanel.addControl(_selector);
  9467. this.selectors.push(_selector);
  9468. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9469. button.color = this.groupPanel.parent.parent.buttonColor;
  9470. button.background = this.groupPanel.parent.parent.buttonBackground;
  9471. }
  9472. };
  9473. /** @hidden */
  9474. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9475. this.selectors[selectorNb].children[0].name = label;
  9476. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9477. };
  9478. /** @hidden */
  9479. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9480. this.selectors[selectorNb].children[0].color = color;
  9481. };
  9482. /** @hidden */
  9483. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9484. this.selectors[selectorNb].children[1].color = color;
  9485. };
  9486. /** @hidden */
  9487. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9488. this.selectors[selectorNb].children[1].background = color;
  9489. };
  9490. return SliderGroup;
  9491. }(SelectorGroup));
  9492. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9493. * @see http://doc.babylonjs.com/how_to/selector
  9494. */
  9495. var SelectionPanel = /** @class */ (function (_super) {
  9496. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9497. /**
  9498. * Creates a new SelectionPanel
  9499. * @param name of SelectionPanel
  9500. * @param groups is an array of SelectionGroups
  9501. */
  9502. function SelectionPanel(
  9503. /** name of SelectionPanel */
  9504. name,
  9505. /** an array of SelectionGroups */
  9506. groups) {
  9507. if (groups === void 0) { groups = []; }
  9508. var _this = _super.call(this, name) || this;
  9509. _this.name = name;
  9510. _this.groups = groups;
  9511. _this._buttonColor = "#364249";
  9512. _this._buttonBackground = "#CCCCCC";
  9513. _this._headerColor = "black";
  9514. _this._barColor = "white";
  9515. _this._barHeight = "2px";
  9516. _this._spacerHeight = "20px";
  9517. _this._bars = new Array();
  9518. _this._groups = groups;
  9519. _this.thickness = 2;
  9520. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9521. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9522. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9523. _this._panel.top = 5;
  9524. _this._panel.left = 5;
  9525. _this._panel.width = 0.95;
  9526. if (groups.length > 0) {
  9527. for (var i = 0; i < groups.length - 1; i++) {
  9528. _this._panel.addControl(groups[i].groupPanel);
  9529. _this._addSpacer();
  9530. }
  9531. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9532. }
  9533. _this.addControl(_this._panel);
  9534. return _this;
  9535. }
  9536. SelectionPanel.prototype._getTypeName = function () {
  9537. return "SelectionPanel";
  9538. };
  9539. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9540. /** Gets or sets the headerColor */
  9541. get: function () {
  9542. return this._headerColor;
  9543. },
  9544. set: function (color) {
  9545. if (this._headerColor === color) {
  9546. return;
  9547. }
  9548. this._headerColor = color;
  9549. this._setHeaderColor();
  9550. },
  9551. enumerable: true,
  9552. configurable: true
  9553. });
  9554. SelectionPanel.prototype._setHeaderColor = function () {
  9555. for (var i = 0; i < this._groups.length; i++) {
  9556. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9557. }
  9558. };
  9559. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9560. /** Gets or sets the button color */
  9561. get: function () {
  9562. return this._buttonColor;
  9563. },
  9564. set: function (color) {
  9565. if (this._buttonColor === color) {
  9566. return;
  9567. }
  9568. this._buttonColor = color;
  9569. this._setbuttonColor();
  9570. },
  9571. enumerable: true,
  9572. configurable: true
  9573. });
  9574. SelectionPanel.prototype._setbuttonColor = function () {
  9575. for (var i = 0; i < this._groups.length; i++) {
  9576. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9577. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9578. }
  9579. }
  9580. };
  9581. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9582. /** Gets or sets the label color */
  9583. get: function () {
  9584. return this._labelColor;
  9585. },
  9586. set: function (color) {
  9587. if (this._labelColor === color) {
  9588. return;
  9589. }
  9590. this._labelColor = color;
  9591. this._setLabelColor();
  9592. },
  9593. enumerable: true,
  9594. configurable: true
  9595. });
  9596. SelectionPanel.prototype._setLabelColor = function () {
  9597. for (var i = 0; i < this._groups.length; i++) {
  9598. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9599. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9600. }
  9601. }
  9602. };
  9603. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9604. /** Gets or sets the button background */
  9605. get: function () {
  9606. return this._buttonBackground;
  9607. },
  9608. set: function (color) {
  9609. if (this._buttonBackground === color) {
  9610. return;
  9611. }
  9612. this._buttonBackground = color;
  9613. this._setButtonBackground();
  9614. },
  9615. enumerable: true,
  9616. configurable: true
  9617. });
  9618. SelectionPanel.prototype._setButtonBackground = function () {
  9619. for (var i = 0; i < this._groups.length; i++) {
  9620. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9621. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9622. }
  9623. }
  9624. };
  9625. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9626. /** Gets or sets the color of separator bar */
  9627. get: function () {
  9628. return this._barColor;
  9629. },
  9630. set: function (color) {
  9631. if (this._barColor === color) {
  9632. return;
  9633. }
  9634. this._barColor = color;
  9635. this._setBarColor();
  9636. },
  9637. enumerable: true,
  9638. configurable: true
  9639. });
  9640. SelectionPanel.prototype._setBarColor = function () {
  9641. for (var i = 0; i < this._bars.length; i++) {
  9642. this._bars[i].children[0].background = this._barColor;
  9643. }
  9644. };
  9645. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9646. /** Gets or sets the height of separator bar */
  9647. get: function () {
  9648. return this._barHeight;
  9649. },
  9650. set: function (value) {
  9651. if (this._barHeight === value) {
  9652. return;
  9653. }
  9654. this._barHeight = value;
  9655. this._setBarHeight();
  9656. },
  9657. enumerable: true,
  9658. configurable: true
  9659. });
  9660. SelectionPanel.prototype._setBarHeight = function () {
  9661. for (var i = 0; i < this._bars.length; i++) {
  9662. this._bars[i].children[0].height = this._barHeight;
  9663. }
  9664. };
  9665. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9666. /** Gets or sets the height of spacers*/
  9667. get: function () {
  9668. return this._spacerHeight;
  9669. },
  9670. set: function (value) {
  9671. if (this._spacerHeight === value) {
  9672. return;
  9673. }
  9674. this._spacerHeight = value;
  9675. this._setSpacerHeight();
  9676. },
  9677. enumerable: true,
  9678. configurable: true
  9679. });
  9680. SelectionPanel.prototype._setSpacerHeight = function () {
  9681. for (var i = 0; i < this._bars.length; i++) {
  9682. this._bars[i].height = this._spacerHeight;
  9683. }
  9684. };
  9685. /** Adds a bar between groups */
  9686. SelectionPanel.prototype._addSpacer = function () {
  9687. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9688. separator.width = 1;
  9689. separator.height = this._spacerHeight;
  9690. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9691. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9692. bar.width = 1;
  9693. bar.height = this._barHeight;
  9694. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9695. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9696. bar.background = this._barColor;
  9697. bar.color = "transparent";
  9698. separator.addControl(bar);
  9699. this._panel.addControl(separator);
  9700. this._bars.push(separator);
  9701. };
  9702. /** Add a group to the selection panel
  9703. * @param group is the selector group to add
  9704. */
  9705. SelectionPanel.prototype.addGroup = function (group) {
  9706. if (this._groups.length > 0) {
  9707. this._addSpacer();
  9708. }
  9709. this._panel.addControl(group.groupPanel);
  9710. this._groups.push(group);
  9711. group.groupPanel.children[0].color = this._headerColor;
  9712. for (var j = 0; j < group.selectors.length; j++) {
  9713. group._setSelectorButtonColor(j, this._buttonColor);
  9714. group._setSelectorButtonBackground(j, this._buttonBackground);
  9715. }
  9716. };
  9717. /** Remove the group from the given position
  9718. * @param groupNb is the position of the group in the list
  9719. */
  9720. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9721. if (groupNb < 0 || groupNb >= this._groups.length) {
  9722. return;
  9723. }
  9724. var group = this._groups[groupNb];
  9725. this._panel.removeControl(group.groupPanel);
  9726. this._groups.splice(groupNb, 1);
  9727. if (groupNb < this._bars.length) {
  9728. this._panel.removeControl(this._bars[groupNb]);
  9729. this._bars.splice(groupNb, 1);
  9730. }
  9731. };
  9732. /** Change a group header label
  9733. * @param label is the new group header label
  9734. * @param groupNb is the number of the group to relabel
  9735. * */
  9736. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9737. if (groupNb < 0 || groupNb >= this._groups.length) {
  9738. return;
  9739. }
  9740. var group = this._groups[groupNb];
  9741. group.groupPanel.children[0].text = label;
  9742. };
  9743. /** Change selector label to the one given
  9744. * @param label is the new selector label
  9745. * @param groupNb is the number of the groupcontaining the selector
  9746. * @param selectorNb is the number of the selector within a group to relabel
  9747. * */
  9748. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9749. if (groupNb < 0 || groupNb >= this._groups.length) {
  9750. return;
  9751. }
  9752. var group = this._groups[groupNb];
  9753. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9754. return;
  9755. }
  9756. group._setSelectorLabel(selectorNb, label);
  9757. };
  9758. /** For a given group position remove the selector at the given position
  9759. * @param groupNb is the number of the group to remove the selector from
  9760. * @param selectorNb is the number of the selector within the group
  9761. */
  9762. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9763. if (groupNb < 0 || groupNb >= this._groups.length) {
  9764. return;
  9765. }
  9766. var group = this._groups[groupNb];
  9767. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9768. return;
  9769. }
  9770. group.removeSelector(selectorNb);
  9771. };
  9772. /** For a given group position of correct type add a checkbox button
  9773. * @param groupNb is the number of the group to remove the selector from
  9774. * @param label is the label for the selector
  9775. * @param func is the function called when the Selector is checked
  9776. * @param checked is true when Selector is checked
  9777. */
  9778. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9779. if (func === void 0) { func = function () { }; }
  9780. if (checked === void 0) { checked = false; }
  9781. if (groupNb < 0 || groupNb >= this._groups.length) {
  9782. return;
  9783. }
  9784. var group = this._groups[groupNb];
  9785. group.addCheckbox(label, func, checked);
  9786. };
  9787. /** For a given group position of correct type add a radio button
  9788. * @param groupNb is the number of the group to remove the selector from
  9789. * @param label is the label for the selector
  9790. * @param func is the function called when the Selector is checked
  9791. * @param checked is true when Selector is checked
  9792. */
  9793. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9794. if (func === void 0) { func = function () { }; }
  9795. if (checked === void 0) { checked = false; }
  9796. if (groupNb < 0 || groupNb >= this._groups.length) {
  9797. return;
  9798. }
  9799. var group = this._groups[groupNb];
  9800. group.addRadio(label, func, checked);
  9801. };
  9802. /**
  9803. * For a given slider group add a slider
  9804. * @param groupNb is the number of the group to add the slider to
  9805. * @param label is the label for the Slider
  9806. * @param func is the function called when the Slider moves
  9807. * @param unit is a string describing the units used, eg degrees or metres
  9808. * @param min is the minimum value for the Slider
  9809. * @param max is the maximum value for the Slider
  9810. * @param value is the start value for the Slider between min and max
  9811. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9812. */
  9813. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9814. if (func === void 0) { func = function () { }; }
  9815. if (unit === void 0) { unit = "Units"; }
  9816. if (min === void 0) { min = 0; }
  9817. if (max === void 0) { max = 0; }
  9818. if (value === void 0) { value = 0; }
  9819. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9820. if (groupNb < 0 || groupNb >= this._groups.length) {
  9821. return;
  9822. }
  9823. var group = this._groups[groupNb];
  9824. group.addSlider(label, func, unit, min, max, value, onVal);
  9825. };
  9826. return SelectionPanel;
  9827. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9828. /***/ }),
  9829. /***/ "./2D/controls/sliders/baseSlider.ts":
  9830. /*!*******************************************!*\
  9831. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9832. \*******************************************/
  9833. /*! exports provided: BaseSlider */
  9834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9835. "use strict";
  9836. __webpack_require__.r(__webpack_exports__);
  9837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9838. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9839. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  9840. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9841. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9842. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9843. /**
  9844. * Class used to create slider controls
  9845. */
  9846. var BaseSlider = /** @class */ (function (_super) {
  9847. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9848. /**
  9849. * Creates a new BaseSlider
  9850. * @param name defines the control name
  9851. */
  9852. function BaseSlider(name) {
  9853. var _this = _super.call(this, name) || this;
  9854. _this.name = name;
  9855. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9856. _this._minimum = 0;
  9857. _this._maximum = 100;
  9858. _this._value = 50;
  9859. _this._isVertical = false;
  9860. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9861. _this._isThumbClamped = false;
  9862. _this._displayThumb = true;
  9863. _this._step = 0;
  9864. _this._lastPointerDownID = -1;
  9865. // Shared rendering info
  9866. _this._effectiveBarOffset = 0;
  9867. /** Observable raised when the sldier value changes */
  9868. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9869. // Events
  9870. _this._pointerIsDown = false;
  9871. _this.isPointerBlocker = true;
  9872. return _this;
  9873. }
  9874. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9875. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9876. get: function () {
  9877. return this._displayThumb;
  9878. },
  9879. set: function (value) {
  9880. if (this._displayThumb === value) {
  9881. return;
  9882. }
  9883. this._displayThumb = value;
  9884. this._markAsDirty();
  9885. },
  9886. enumerable: true,
  9887. configurable: true
  9888. });
  9889. Object.defineProperty(BaseSlider.prototype, "step", {
  9890. /** Gets or sets a step to apply to values (0 by default) */
  9891. get: function () {
  9892. return this._step;
  9893. },
  9894. set: function (value) {
  9895. if (this._step === value) {
  9896. return;
  9897. }
  9898. this._step = value;
  9899. this._markAsDirty();
  9900. },
  9901. enumerable: true,
  9902. configurable: true
  9903. });
  9904. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9905. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9906. get: function () {
  9907. return this._barOffset.toString(this._host);
  9908. },
  9909. set: function (value) {
  9910. if (this._barOffset.toString(this._host) === value) {
  9911. return;
  9912. }
  9913. if (this._barOffset.fromString(value)) {
  9914. this._markAsDirty();
  9915. }
  9916. },
  9917. enumerable: true,
  9918. configurable: true
  9919. });
  9920. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9921. /** Gets main bar offset in pixels*/
  9922. get: function () {
  9923. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9924. },
  9925. enumerable: true,
  9926. configurable: true
  9927. });
  9928. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9929. /** Gets or sets thumb width */
  9930. get: function () {
  9931. return this._thumbWidth.toString(this._host);
  9932. },
  9933. set: function (value) {
  9934. if (this._thumbWidth.toString(this._host) === value) {
  9935. return;
  9936. }
  9937. if (this._thumbWidth.fromString(value)) {
  9938. this._markAsDirty();
  9939. }
  9940. },
  9941. enumerable: true,
  9942. configurable: true
  9943. });
  9944. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9945. /** Gets thumb width in pixels */
  9946. get: function () {
  9947. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9948. },
  9949. enumerable: true,
  9950. configurable: true
  9951. });
  9952. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9953. /** Gets or sets minimum value */
  9954. get: function () {
  9955. return this._minimum;
  9956. },
  9957. set: function (value) {
  9958. if (this._minimum === value) {
  9959. return;
  9960. }
  9961. this._minimum = value;
  9962. this._markAsDirty();
  9963. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9964. },
  9965. enumerable: true,
  9966. configurable: true
  9967. });
  9968. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9969. /** Gets or sets maximum value */
  9970. get: function () {
  9971. return this._maximum;
  9972. },
  9973. set: function (value) {
  9974. if (this._maximum === value) {
  9975. return;
  9976. }
  9977. this._maximum = value;
  9978. this._markAsDirty();
  9979. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9980. },
  9981. enumerable: true,
  9982. configurable: true
  9983. });
  9984. Object.defineProperty(BaseSlider.prototype, "value", {
  9985. /** Gets or sets current value */
  9986. get: function () {
  9987. return this._value;
  9988. },
  9989. set: function (value) {
  9990. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9991. if (this._value === value) {
  9992. return;
  9993. }
  9994. this._value = value;
  9995. this._markAsDirty();
  9996. this.onValueChangedObservable.notifyObservers(this._value);
  9997. },
  9998. enumerable: true,
  9999. configurable: true
  10000. });
  10001. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10002. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10003. get: function () {
  10004. return this._isVertical;
  10005. },
  10006. set: function (value) {
  10007. if (this._isVertical === value) {
  10008. return;
  10009. }
  10010. this._isVertical = value;
  10011. this._markAsDirty();
  10012. },
  10013. enumerable: true,
  10014. configurable: true
  10015. });
  10016. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10017. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10018. get: function () {
  10019. return this._isThumbClamped;
  10020. },
  10021. set: function (value) {
  10022. if (this._isThumbClamped === value) {
  10023. return;
  10024. }
  10025. this._isThumbClamped = value;
  10026. this._markAsDirty();
  10027. },
  10028. enumerable: true,
  10029. configurable: true
  10030. });
  10031. BaseSlider.prototype._getTypeName = function () {
  10032. return "BaseSlider";
  10033. };
  10034. BaseSlider.prototype._getThumbPosition = function () {
  10035. if (this.isVertical) {
  10036. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10037. }
  10038. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10039. };
  10040. BaseSlider.prototype._getThumbThickness = function (type) {
  10041. var thumbThickness = 0;
  10042. switch (type) {
  10043. case "circle":
  10044. if (this._thumbWidth.isPixel) {
  10045. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10046. }
  10047. else {
  10048. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10049. }
  10050. break;
  10051. case "rectangle":
  10052. if (this._thumbWidth.isPixel) {
  10053. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10054. }
  10055. else {
  10056. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10057. }
  10058. }
  10059. return thumbThickness;
  10060. };
  10061. BaseSlider.prototype._prepareRenderingData = function (type) {
  10062. // Main bar
  10063. this._effectiveBarOffset = 0;
  10064. this._renderLeft = this._currentMeasure.left;
  10065. this._renderTop = this._currentMeasure.top;
  10066. this._renderWidth = this._currentMeasure.width;
  10067. this._renderHeight = this._currentMeasure.height;
  10068. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10069. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10070. this._effectiveThumbThickness = this._getThumbThickness(type);
  10071. if (this.displayThumb) {
  10072. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10073. }
  10074. //throw error when height is less than width for vertical slider
  10075. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10076. console.error("Height should be greater than width");
  10077. return;
  10078. }
  10079. if (this._barOffset.isPixel) {
  10080. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10081. }
  10082. else {
  10083. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10084. }
  10085. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10086. if (this.isVertical) {
  10087. this._renderLeft += this._effectiveBarOffset;
  10088. if (!this.isThumbClamped && this.displayThumb) {
  10089. this._renderTop += (this._effectiveThumbThickness / 2);
  10090. }
  10091. this._renderHeight = this._backgroundBoxLength;
  10092. this._renderWidth = this._backgroundBoxThickness;
  10093. }
  10094. else {
  10095. this._renderTop += this._effectiveBarOffset;
  10096. if (!this.isThumbClamped && this.displayThumb) {
  10097. this._renderLeft += (this._effectiveThumbThickness / 2);
  10098. }
  10099. this._renderHeight = this._backgroundBoxThickness;
  10100. this._renderWidth = this._backgroundBoxLength;
  10101. }
  10102. };
  10103. /** @hidden */
  10104. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10105. if (this.rotation != 0) {
  10106. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10107. x = this._transformedPosition.x;
  10108. y = this._transformedPosition.y;
  10109. }
  10110. var value;
  10111. if (this._isVertical) {
  10112. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10113. }
  10114. else {
  10115. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10116. }
  10117. var mult = (1 / this._step) | 0;
  10118. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10119. };
  10120. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10121. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10122. return false;
  10123. }
  10124. this._pointerIsDown = true;
  10125. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10126. this._host._capturingControl[pointerId] = this;
  10127. this._lastPointerDownID = pointerId;
  10128. return true;
  10129. };
  10130. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10131. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10132. if (pointerId != this._lastPointerDownID) {
  10133. return;
  10134. }
  10135. if (this._pointerIsDown) {
  10136. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10137. }
  10138. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10139. };
  10140. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10141. this._pointerIsDown = false;
  10142. delete this._host._capturingControl[pointerId];
  10143. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10144. };
  10145. return BaseSlider;
  10146. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10147. /***/ }),
  10148. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10149. /*!*************************************************!*\
  10150. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10151. \*************************************************/
  10152. /*! exports provided: ImageBasedSlider */
  10153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10154. "use strict";
  10155. __webpack_require__.r(__webpack_exports__);
  10156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10157. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10158. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10159. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10160. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10161. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10162. /**
  10163. * Class used to create slider controls based on images
  10164. */
  10165. var ImageBasedSlider = /** @class */ (function (_super) {
  10166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10167. /**
  10168. * Creates a new ImageBasedSlider
  10169. * @param name defines the control name
  10170. */
  10171. function ImageBasedSlider(name) {
  10172. var _this = _super.call(this, name) || this;
  10173. _this.name = name;
  10174. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10175. return _this;
  10176. }
  10177. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10178. get: function () {
  10179. return this._displayThumb && this.thumbImage != null;
  10180. },
  10181. set: function (value) {
  10182. if (this._displayThumb === value) {
  10183. return;
  10184. }
  10185. this._displayThumb = value;
  10186. this._markAsDirty();
  10187. },
  10188. enumerable: true,
  10189. configurable: true
  10190. });
  10191. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10192. /**
  10193. * Gets or sets the image used to render the background
  10194. */
  10195. get: function () {
  10196. return this._backgroundImage;
  10197. },
  10198. set: function (value) {
  10199. var _this = this;
  10200. if (this._backgroundImage === value) {
  10201. return;
  10202. }
  10203. this._backgroundImage = value;
  10204. if (value && !value.isLoaded) {
  10205. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10206. }
  10207. this._markAsDirty();
  10208. },
  10209. enumerable: true,
  10210. configurable: true
  10211. });
  10212. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10213. /**
  10214. * Gets or sets the image used to render the value bar
  10215. */
  10216. get: function () {
  10217. return this._valueBarImage;
  10218. },
  10219. set: function (value) {
  10220. var _this = this;
  10221. if (this._valueBarImage === value) {
  10222. return;
  10223. }
  10224. this._valueBarImage = value;
  10225. if (value && !value.isLoaded) {
  10226. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10227. }
  10228. this._markAsDirty();
  10229. },
  10230. enumerable: true,
  10231. configurable: true
  10232. });
  10233. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10234. /**
  10235. * Gets or sets the image used to render the thumb
  10236. */
  10237. get: function () {
  10238. return this._thumbImage;
  10239. },
  10240. set: function (value) {
  10241. var _this = this;
  10242. if (this._thumbImage === value) {
  10243. return;
  10244. }
  10245. this._thumbImage = value;
  10246. if (value && !value.isLoaded) {
  10247. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10248. }
  10249. this._markAsDirty();
  10250. },
  10251. enumerable: true,
  10252. configurable: true
  10253. });
  10254. ImageBasedSlider.prototype._getTypeName = function () {
  10255. return "ImageBasedSlider";
  10256. };
  10257. ImageBasedSlider.prototype._draw = function (context) {
  10258. context.save();
  10259. this._applyStates(context);
  10260. this._prepareRenderingData("rectangle");
  10261. var thumbPosition = this._getThumbPosition();
  10262. var left = this._renderLeft;
  10263. var top = this._renderTop;
  10264. var width = this._renderWidth;
  10265. var height = this._renderHeight;
  10266. // Background
  10267. if (this._backgroundImage) {
  10268. this._tempMeasure.copyFromFloats(left, top, width, height);
  10269. if (this.isThumbClamped && this.displayThumb) {
  10270. if (this.isVertical) {
  10271. this._tempMeasure.height += this._effectiveThumbThickness;
  10272. }
  10273. else {
  10274. this._tempMeasure.width += this._effectiveThumbThickness;
  10275. }
  10276. }
  10277. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10278. this._backgroundImage._draw(context);
  10279. }
  10280. // Bar
  10281. if (this._valueBarImage) {
  10282. if (this.isVertical) {
  10283. if (this.isThumbClamped && this.displayThumb) {
  10284. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10285. }
  10286. else {
  10287. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10288. }
  10289. }
  10290. else {
  10291. if (this.isThumbClamped && this.displayThumb) {
  10292. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10293. }
  10294. else {
  10295. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10296. }
  10297. }
  10298. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10299. this._valueBarImage._draw(context);
  10300. }
  10301. // Thumb
  10302. if (this.displayThumb) {
  10303. if (this.isVertical) {
  10304. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10305. }
  10306. else {
  10307. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10308. }
  10309. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10310. this._thumbImage._draw(context);
  10311. }
  10312. context.restore();
  10313. };
  10314. return ImageBasedSlider;
  10315. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10316. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10317. /***/ }),
  10318. /***/ "./2D/controls/sliders/scrollBar.ts":
  10319. /*!******************************************!*\
  10320. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10321. \******************************************/
  10322. /*! exports provided: ScrollBar */
  10323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10324. "use strict";
  10325. __webpack_require__.r(__webpack_exports__);
  10326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10327. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10328. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10329. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10330. /**
  10331. * Class used to create slider controls
  10332. */
  10333. var ScrollBar = /** @class */ (function (_super) {
  10334. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10335. /**
  10336. * Creates a new Slider
  10337. * @param name defines the control name
  10338. */
  10339. function ScrollBar(name) {
  10340. var _this = _super.call(this, name) || this;
  10341. _this.name = name;
  10342. _this._background = "black";
  10343. _this._borderColor = "white";
  10344. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10345. return _this;
  10346. }
  10347. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10348. /** Gets or sets border color */
  10349. get: function () {
  10350. return this._borderColor;
  10351. },
  10352. set: function (value) {
  10353. if (this._borderColor === value) {
  10354. return;
  10355. }
  10356. this._borderColor = value;
  10357. this._markAsDirty();
  10358. },
  10359. enumerable: true,
  10360. configurable: true
  10361. });
  10362. Object.defineProperty(ScrollBar.prototype, "background", {
  10363. /** Gets or sets background color */
  10364. get: function () {
  10365. return this._background;
  10366. },
  10367. set: function (value) {
  10368. if (this._background === value) {
  10369. return;
  10370. }
  10371. this._background = value;
  10372. this._markAsDirty();
  10373. },
  10374. enumerable: true,
  10375. configurable: true
  10376. });
  10377. ScrollBar.prototype._getTypeName = function () {
  10378. return "Scrollbar";
  10379. };
  10380. ScrollBar.prototype._getThumbThickness = function () {
  10381. var thumbThickness = 0;
  10382. if (this._thumbWidth.isPixel) {
  10383. thumbThickness = this._thumbWidth.getValue(this._host);
  10384. }
  10385. else {
  10386. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10387. }
  10388. return thumbThickness;
  10389. };
  10390. ScrollBar.prototype._draw = function (context) {
  10391. context.save();
  10392. this._applyStates(context);
  10393. this._prepareRenderingData("rectangle");
  10394. var left = this._renderLeft;
  10395. var thumbPosition = this._getThumbPosition();
  10396. context.fillStyle = this._background;
  10397. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10398. // Value bar
  10399. context.fillStyle = this.color;
  10400. // Thumb
  10401. if (this.isVertical) {
  10402. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10403. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10404. this._thumbMeasure.width = this._currentMeasure.width;
  10405. this._thumbMeasure.height = this._effectiveThumbThickness;
  10406. }
  10407. else {
  10408. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10409. this._thumbMeasure.top = this._currentMeasure.top;
  10410. this._thumbMeasure.width = this._effectiveThumbThickness;
  10411. this._thumbMeasure.height = this._currentMeasure.height;
  10412. }
  10413. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10414. context.restore();
  10415. };
  10416. /** @hidden */
  10417. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10418. if (this.rotation != 0) {
  10419. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10420. x = this._transformedPosition.x;
  10421. y = this._transformedPosition.y;
  10422. }
  10423. if (this._first) {
  10424. this._first = false;
  10425. this._originX = x;
  10426. this._originY = y;
  10427. // Check if move is required
  10428. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10429. if (this.isVertical) {
  10430. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10431. }
  10432. else {
  10433. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10434. }
  10435. }
  10436. }
  10437. // Delta mode
  10438. var delta = 0;
  10439. if (this.isVertical) {
  10440. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10441. }
  10442. else {
  10443. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10444. }
  10445. this.value += delta * (this.maximum - this.minimum);
  10446. this._originX = x;
  10447. this._originY = y;
  10448. };
  10449. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10450. this._first = true;
  10451. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10452. };
  10453. return ScrollBar;
  10454. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10455. /***/ }),
  10456. /***/ "./2D/controls/sliders/slider.ts":
  10457. /*!***************************************!*\
  10458. !*** ./2D/controls/sliders/slider.ts ***!
  10459. \***************************************/
  10460. /*! exports provided: Slider */
  10461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10462. "use strict";
  10463. __webpack_require__.r(__webpack_exports__);
  10464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10465. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10466. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10467. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10468. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  10469. /**
  10470. * Class used to create slider controls
  10471. */
  10472. var Slider = /** @class */ (function (_super) {
  10473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10474. /**
  10475. * Creates a new Slider
  10476. * @param name defines the control name
  10477. */
  10478. function Slider(name) {
  10479. var _this = _super.call(this, name) || this;
  10480. _this.name = name;
  10481. _this._background = "black";
  10482. _this._borderColor = "white";
  10483. _this._isThumbCircle = false;
  10484. _this._displayValueBar = true;
  10485. return _this;
  10486. }
  10487. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10488. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10489. get: function () {
  10490. return this._displayValueBar;
  10491. },
  10492. set: function (value) {
  10493. if (this._displayValueBar === value) {
  10494. return;
  10495. }
  10496. this._displayValueBar = value;
  10497. this._markAsDirty();
  10498. },
  10499. enumerable: true,
  10500. configurable: true
  10501. });
  10502. Object.defineProperty(Slider.prototype, "borderColor", {
  10503. /** Gets or sets border color */
  10504. get: function () {
  10505. return this._borderColor;
  10506. },
  10507. set: function (value) {
  10508. if (this._borderColor === value) {
  10509. return;
  10510. }
  10511. this._borderColor = value;
  10512. this._markAsDirty();
  10513. },
  10514. enumerable: true,
  10515. configurable: true
  10516. });
  10517. Object.defineProperty(Slider.prototype, "background", {
  10518. /** Gets or sets background color */
  10519. get: function () {
  10520. return this._background;
  10521. },
  10522. set: function (value) {
  10523. if (this._background === value) {
  10524. return;
  10525. }
  10526. this._background = value;
  10527. this._markAsDirty();
  10528. },
  10529. enumerable: true,
  10530. configurable: true
  10531. });
  10532. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10533. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10534. get: function () {
  10535. return this._isThumbCircle;
  10536. },
  10537. set: function (value) {
  10538. if (this._isThumbCircle === value) {
  10539. return;
  10540. }
  10541. this._isThumbCircle = value;
  10542. this._markAsDirty();
  10543. },
  10544. enumerable: true,
  10545. configurable: true
  10546. });
  10547. Slider.prototype._getTypeName = function () {
  10548. return "Slider";
  10549. };
  10550. Slider.prototype._draw = function (context) {
  10551. context.save();
  10552. this._applyStates(context);
  10553. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10554. var left = this._renderLeft;
  10555. var top = this._renderTop;
  10556. var width = this._renderWidth;
  10557. var height = this._renderHeight;
  10558. var radius = 0;
  10559. if (this.isThumbClamped && this.isThumbCircle) {
  10560. if (this.isVertical) {
  10561. top += (this._effectiveThumbThickness / 2);
  10562. }
  10563. else {
  10564. left += (this._effectiveThumbThickness / 2);
  10565. }
  10566. radius = this._backgroundBoxThickness / 2;
  10567. }
  10568. else {
  10569. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10570. }
  10571. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10572. context.shadowColor = this.shadowColor;
  10573. context.shadowBlur = this.shadowBlur;
  10574. context.shadowOffsetX = this.shadowOffsetX;
  10575. context.shadowOffsetY = this.shadowOffsetY;
  10576. }
  10577. var thumbPosition = this._getThumbPosition();
  10578. context.fillStyle = this._background;
  10579. if (this.isVertical) {
  10580. if (this.isThumbClamped) {
  10581. if (this.isThumbCircle) {
  10582. context.beginPath();
  10583. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10584. context.fill();
  10585. context.fillRect(left, top, width, height);
  10586. }
  10587. else {
  10588. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10589. }
  10590. }
  10591. else {
  10592. context.fillRect(left, top, width, height);
  10593. }
  10594. }
  10595. else {
  10596. if (this.isThumbClamped) {
  10597. if (this.isThumbCircle) {
  10598. context.beginPath();
  10599. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10600. context.fill();
  10601. context.fillRect(left, top, width, height);
  10602. }
  10603. else {
  10604. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10605. }
  10606. }
  10607. else {
  10608. context.fillRect(left, top, width, height);
  10609. }
  10610. }
  10611. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10612. context.shadowBlur = 0;
  10613. context.shadowOffsetX = 0;
  10614. context.shadowOffsetY = 0;
  10615. }
  10616. // Value bar
  10617. context.fillStyle = this.color;
  10618. if (this._displayValueBar) {
  10619. if (this.isVertical) {
  10620. if (this.isThumbClamped) {
  10621. if (this.isThumbCircle) {
  10622. context.beginPath();
  10623. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10624. context.fill();
  10625. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10626. }
  10627. else {
  10628. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10629. }
  10630. }
  10631. else {
  10632. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10633. }
  10634. }
  10635. else {
  10636. if (this.isThumbClamped) {
  10637. if (this.isThumbCircle) {
  10638. context.beginPath();
  10639. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10640. context.fill();
  10641. context.fillRect(left, top, thumbPosition, height);
  10642. }
  10643. else {
  10644. context.fillRect(left, top, thumbPosition, height);
  10645. }
  10646. }
  10647. else {
  10648. context.fillRect(left, top, thumbPosition, height);
  10649. }
  10650. }
  10651. }
  10652. // Thumb
  10653. if (this.displayThumb) {
  10654. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10655. context.shadowColor = this.shadowColor;
  10656. context.shadowBlur = this.shadowBlur;
  10657. context.shadowOffsetX = this.shadowOffsetX;
  10658. context.shadowOffsetY = this.shadowOffsetY;
  10659. }
  10660. if (this._isThumbCircle) {
  10661. context.beginPath();
  10662. if (this.isVertical) {
  10663. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10664. }
  10665. else {
  10666. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10667. }
  10668. context.fill();
  10669. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10670. context.shadowBlur = 0;
  10671. context.shadowOffsetX = 0;
  10672. context.shadowOffsetY = 0;
  10673. }
  10674. context.strokeStyle = this._borderColor;
  10675. context.stroke();
  10676. }
  10677. else {
  10678. if (this.isVertical) {
  10679. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10680. }
  10681. else {
  10682. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10683. }
  10684. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10685. context.shadowBlur = 0;
  10686. context.shadowOffsetX = 0;
  10687. context.shadowOffsetY = 0;
  10688. }
  10689. context.strokeStyle = this._borderColor;
  10690. if (this.isVertical) {
  10691. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10692. }
  10693. else {
  10694. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10695. }
  10696. }
  10697. }
  10698. context.restore();
  10699. };
  10700. return Slider;
  10701. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10702. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  10703. /***/ }),
  10704. /***/ "./2D/controls/stackPanel.ts":
  10705. /*!***********************************!*\
  10706. !*** ./2D/controls/stackPanel.ts ***!
  10707. \***********************************/
  10708. /*! exports provided: StackPanel */
  10709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10710. "use strict";
  10711. __webpack_require__.r(__webpack_exports__);
  10712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10714. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  10715. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10716. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10717. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10718. /**
  10719. * Class used to create a 2D stack panel container
  10720. */
  10721. var StackPanel = /** @class */ (function (_super) {
  10722. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10723. /**
  10724. * Creates a new StackPanel
  10725. * @param name defines control name
  10726. */
  10727. function StackPanel(name) {
  10728. var _this = _super.call(this, name) || this;
  10729. _this.name = name;
  10730. _this._isVertical = true;
  10731. _this._manualWidth = false;
  10732. _this._manualHeight = false;
  10733. _this._doNotTrackManualChanges = false;
  10734. /**
  10735. * Gets or sets a boolean indicating that layou warnings should be ignored
  10736. */
  10737. _this.ignoreLayoutWarnings = false;
  10738. return _this;
  10739. }
  10740. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10741. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10742. get: function () {
  10743. return this._isVertical;
  10744. },
  10745. set: function (value) {
  10746. if (this._isVertical === value) {
  10747. return;
  10748. }
  10749. this._isVertical = value;
  10750. this._markAsDirty();
  10751. },
  10752. enumerable: true,
  10753. configurable: true
  10754. });
  10755. Object.defineProperty(StackPanel.prototype, "width", {
  10756. get: function () {
  10757. return this._width.toString(this._host);
  10758. },
  10759. /**
  10760. * Gets or sets panel width.
  10761. * This value should not be set when in horizontal mode as it will be computed automatically
  10762. */
  10763. set: function (value) {
  10764. if (!this._doNotTrackManualChanges) {
  10765. this._manualWidth = true;
  10766. }
  10767. if (this._width.toString(this._host) === value) {
  10768. return;
  10769. }
  10770. if (this._width.fromString(value)) {
  10771. this._markAsDirty();
  10772. }
  10773. },
  10774. enumerable: true,
  10775. configurable: true
  10776. });
  10777. Object.defineProperty(StackPanel.prototype, "height", {
  10778. get: function () {
  10779. return this._height.toString(this._host);
  10780. },
  10781. /**
  10782. * Gets or sets panel height.
  10783. * This value should not be set when in vertical mode as it will be computed automatically
  10784. */
  10785. set: function (value) {
  10786. if (!this._doNotTrackManualChanges) {
  10787. this._manualHeight = true;
  10788. }
  10789. if (this._height.toString(this._host) === value) {
  10790. return;
  10791. }
  10792. if (this._height.fromString(value)) {
  10793. this._markAsDirty();
  10794. }
  10795. },
  10796. enumerable: true,
  10797. configurable: true
  10798. });
  10799. StackPanel.prototype._getTypeName = function () {
  10800. return "StackPanel";
  10801. };
  10802. /** @hidden */
  10803. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10804. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10805. var child = _a[_i];
  10806. if (this._isVertical) {
  10807. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10808. }
  10809. else {
  10810. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10811. }
  10812. }
  10813. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10814. };
  10815. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10816. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10817. this._measureForChildren.copyFrom(parentMeasure);
  10818. this._measureForChildren.left = this._currentMeasure.left;
  10819. this._measureForChildren.top = this._currentMeasure.top;
  10820. if (!this.isVertical || this._manualWidth) {
  10821. this._measureForChildren.width = this._currentMeasure.width;
  10822. }
  10823. if (this.isVertical || this._manualHeight) {
  10824. this._measureForChildren.height = this._currentMeasure.height;
  10825. }
  10826. };
  10827. StackPanel.prototype._postMeasure = function () {
  10828. var stackWidth = 0;
  10829. var stackHeight = 0;
  10830. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10831. var child = _a[_i];
  10832. if (!child.isVisible || child.notRenderable) {
  10833. continue;
  10834. }
  10835. if (this._isVertical) {
  10836. if (child.top !== stackHeight + "px") {
  10837. child.top = stackHeight + "px";
  10838. this._rebuildLayout = true;
  10839. child._top.ignoreAdaptiveScaling = true;
  10840. }
  10841. if (child._height.isPercentage) {
  10842. if (!this.ignoreLayoutWarnings) {
  10843. 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");
  10844. }
  10845. }
  10846. else {
  10847. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10848. }
  10849. }
  10850. else {
  10851. if (child.left !== stackWidth + "px") {
  10852. child.left = stackWidth + "px";
  10853. this._rebuildLayout = true;
  10854. child._left.ignoreAdaptiveScaling = true;
  10855. }
  10856. if (child._width.isPercentage) {
  10857. if (!this.ignoreLayoutWarnings) {
  10858. 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");
  10859. }
  10860. }
  10861. else {
  10862. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10863. }
  10864. }
  10865. }
  10866. this._doNotTrackManualChanges = true;
  10867. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10868. // User can now define their own height and width for stack panel.
  10869. var panelWidthChanged = false;
  10870. var panelHeightChanged = false;
  10871. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10872. var previousHeight = this.height;
  10873. this.height = stackHeight + "px";
  10874. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10875. }
  10876. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10877. var previousWidth = this.width;
  10878. this.width = stackWidth + "px";
  10879. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10880. }
  10881. if (panelHeightChanged) {
  10882. this._height.ignoreAdaptiveScaling = true;
  10883. }
  10884. if (panelWidthChanged) {
  10885. this._width.ignoreAdaptiveScaling = true;
  10886. }
  10887. this._doNotTrackManualChanges = false;
  10888. if (panelWidthChanged || panelHeightChanged) {
  10889. this._rebuildLayout = true;
  10890. }
  10891. _super.prototype._postMeasure.call(this);
  10892. };
  10893. return StackPanel;
  10894. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10895. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  10896. /***/ }),
  10897. /***/ "./2D/controls/statics.ts":
  10898. /*!********************************!*\
  10899. !*** ./2D/controls/statics.ts ***!
  10900. \********************************/
  10901. /*! exports provided: name */
  10902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10903. "use strict";
  10904. __webpack_require__.r(__webpack_exports__);
  10905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10906. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10907. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10908. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10909. /**
  10910. * Forcing an export so that this code will execute
  10911. * @hidden
  10912. */
  10913. var name = "Statics";
  10914. /**
  10915. * Creates a stack panel that can be used to render headers
  10916. * @param control defines the control to associate with the header
  10917. * @param text defines the text of the header
  10918. * @param size defines the size of the header
  10919. * @param options defines options used to configure the header
  10920. * @returns a new StackPanel
  10921. */
  10922. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10923. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10924. var isHorizontal = options ? options.isHorizontal : true;
  10925. var controlFirst = options ? options.controlFirst : true;
  10926. panel.isVertical = !isHorizontal;
  10927. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10928. header.text = text;
  10929. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10930. if (isHorizontal) {
  10931. header.width = size;
  10932. }
  10933. else {
  10934. header.height = size;
  10935. }
  10936. if (controlFirst) {
  10937. panel.addControl(control);
  10938. panel.addControl(header);
  10939. header.paddingLeft = "5px";
  10940. }
  10941. else {
  10942. panel.addControl(header);
  10943. panel.addControl(control);
  10944. header.paddingRight = "5px";
  10945. }
  10946. header.shadowBlur = control.shadowBlur;
  10947. header.shadowColor = control.shadowColor;
  10948. header.shadowOffsetX = control.shadowOffsetX;
  10949. header.shadowOffsetY = control.shadowOffsetY;
  10950. return panel;
  10951. };
  10952. /***/ }),
  10953. /***/ "./2D/controls/textBlock.ts":
  10954. /*!**********************************!*\
  10955. !*** ./2D/controls/textBlock.ts ***!
  10956. \**********************************/
  10957. /*! exports provided: TextWrapping, TextBlock */
  10958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10959. "use strict";
  10960. __webpack_require__.r(__webpack_exports__);
  10961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10963. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10964. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  10965. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10966. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10967. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10968. /**
  10969. * Enum that determines the text-wrapping mode to use.
  10970. */
  10971. var TextWrapping;
  10972. (function (TextWrapping) {
  10973. /**
  10974. * Clip the text when it's larger than Control.width; this is the default mode.
  10975. */
  10976. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10977. /**
  10978. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10979. */
  10980. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10981. /**
  10982. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10983. */
  10984. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10985. })(TextWrapping || (TextWrapping = {}));
  10986. /**
  10987. * Class used to create text block control
  10988. */
  10989. var TextBlock = /** @class */ (function (_super) {
  10990. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10991. /**
  10992. * Creates a new TextBlock object
  10993. * @param name defines the name of the control
  10994. * @param text defines the text to display (emptry string by default)
  10995. */
  10996. function TextBlock(
  10997. /**
  10998. * Defines the name of the control
  10999. */
  11000. name, text) {
  11001. if (text === void 0) { text = ""; }
  11002. var _this = _super.call(this, name) || this;
  11003. _this.name = name;
  11004. _this._text = "";
  11005. _this._textWrapping = TextWrapping.Clip;
  11006. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11007. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11008. _this._resizeToFit = false;
  11009. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11010. _this._outlineWidth = 0;
  11011. _this._outlineColor = "white";
  11012. /**
  11013. * An event triggered after the text is changed
  11014. */
  11015. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11016. /**
  11017. * An event triggered after the text was broken up into lines
  11018. */
  11019. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11020. _this.text = text;
  11021. return _this;
  11022. }
  11023. Object.defineProperty(TextBlock.prototype, "lines", {
  11024. /**
  11025. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11026. */
  11027. get: function () {
  11028. return this._lines;
  11029. },
  11030. enumerable: true,
  11031. configurable: true
  11032. });
  11033. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11034. /**
  11035. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11036. */
  11037. get: function () {
  11038. return this._resizeToFit;
  11039. },
  11040. /**
  11041. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11042. */
  11043. set: function (value) {
  11044. if (this._resizeToFit === value) {
  11045. return;
  11046. }
  11047. this._resizeToFit = value;
  11048. if (this._resizeToFit) {
  11049. this._width.ignoreAdaptiveScaling = true;
  11050. this._height.ignoreAdaptiveScaling = true;
  11051. }
  11052. this._markAsDirty();
  11053. },
  11054. enumerable: true,
  11055. configurable: true
  11056. });
  11057. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11058. /**
  11059. * Gets or sets a boolean indicating if text must be wrapped
  11060. */
  11061. get: function () {
  11062. return this._textWrapping;
  11063. },
  11064. /**
  11065. * Gets or sets a boolean indicating if text must be wrapped
  11066. */
  11067. set: function (value) {
  11068. if (this._textWrapping === value) {
  11069. return;
  11070. }
  11071. this._textWrapping = +value;
  11072. this._markAsDirty();
  11073. },
  11074. enumerable: true,
  11075. configurable: true
  11076. });
  11077. Object.defineProperty(TextBlock.prototype, "text", {
  11078. /**
  11079. * Gets or sets text to display
  11080. */
  11081. get: function () {
  11082. return this._text;
  11083. },
  11084. /**
  11085. * Gets or sets text to display
  11086. */
  11087. set: function (value) {
  11088. if (this._text === value) {
  11089. return;
  11090. }
  11091. this._text = value;
  11092. this._markAsDirty();
  11093. this.onTextChangedObservable.notifyObservers(this);
  11094. },
  11095. enumerable: true,
  11096. configurable: true
  11097. });
  11098. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11099. /**
  11100. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11101. */
  11102. get: function () {
  11103. return this._textHorizontalAlignment;
  11104. },
  11105. /**
  11106. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11107. */
  11108. set: function (value) {
  11109. if (this._textHorizontalAlignment === value) {
  11110. return;
  11111. }
  11112. this._textHorizontalAlignment = value;
  11113. this._markAsDirty();
  11114. },
  11115. enumerable: true,
  11116. configurable: true
  11117. });
  11118. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11119. /**
  11120. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11121. */
  11122. get: function () {
  11123. return this._textVerticalAlignment;
  11124. },
  11125. /**
  11126. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11127. */
  11128. set: function (value) {
  11129. if (this._textVerticalAlignment === value) {
  11130. return;
  11131. }
  11132. this._textVerticalAlignment = value;
  11133. this._markAsDirty();
  11134. },
  11135. enumerable: true,
  11136. configurable: true
  11137. });
  11138. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11139. /**
  11140. * Gets or sets line spacing value
  11141. */
  11142. get: function () {
  11143. return this._lineSpacing.toString(this._host);
  11144. },
  11145. /**
  11146. * Gets or sets line spacing value
  11147. */
  11148. set: function (value) {
  11149. if (this._lineSpacing.fromString(value)) {
  11150. this._markAsDirty();
  11151. }
  11152. },
  11153. enumerable: true,
  11154. configurable: true
  11155. });
  11156. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11157. /**
  11158. * Gets or sets outlineWidth of the text to display
  11159. */
  11160. get: function () {
  11161. return this._outlineWidth;
  11162. },
  11163. /**
  11164. * Gets or sets outlineWidth of the text to display
  11165. */
  11166. set: function (value) {
  11167. if (this._outlineWidth === value) {
  11168. return;
  11169. }
  11170. this._outlineWidth = value;
  11171. this._markAsDirty();
  11172. },
  11173. enumerable: true,
  11174. configurable: true
  11175. });
  11176. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11177. /**
  11178. * Gets or sets outlineColor of the text to display
  11179. */
  11180. get: function () {
  11181. return this._outlineColor;
  11182. },
  11183. /**
  11184. * Gets or sets outlineColor of the text to display
  11185. */
  11186. set: function (value) {
  11187. if (this._outlineColor === value) {
  11188. return;
  11189. }
  11190. this._outlineColor = value;
  11191. this._markAsDirty();
  11192. },
  11193. enumerable: true,
  11194. configurable: true
  11195. });
  11196. TextBlock.prototype._getTypeName = function () {
  11197. return "TextBlock";
  11198. };
  11199. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11200. if (!this._fontOffset) {
  11201. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11202. }
  11203. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11204. // Prepare lines
  11205. this._lines = this._breakLines(this._currentMeasure.width, context);
  11206. this.onLinesReadyObservable.notifyObservers(this);
  11207. var maxLineWidth = 0;
  11208. for (var i = 0; i < this._lines.length; i++) {
  11209. var line = this._lines[i];
  11210. if (line.width > maxLineWidth) {
  11211. maxLineWidth = line.width;
  11212. }
  11213. }
  11214. if (this._resizeToFit) {
  11215. if (this._textWrapping === TextWrapping.Clip) {
  11216. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11217. if (newWidth !== this._width.internalValue) {
  11218. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11219. this._rebuildLayout = true;
  11220. }
  11221. }
  11222. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11223. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11224. var lineSpacing = 0;
  11225. if (this._lineSpacing.isPixel) {
  11226. lineSpacing = this._lineSpacing.getValue(this._host);
  11227. }
  11228. else {
  11229. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11230. }
  11231. newHeight += (this._lines.length - 1) * lineSpacing;
  11232. }
  11233. if (newHeight !== this._height.internalValue) {
  11234. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11235. this._rebuildLayout = true;
  11236. }
  11237. }
  11238. };
  11239. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11240. var width = this._currentMeasure.width;
  11241. var x = 0;
  11242. switch (this._textHorizontalAlignment) {
  11243. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11244. x = 0;
  11245. break;
  11246. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11247. x = width - textWidth;
  11248. break;
  11249. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11250. x = (width - textWidth) / 2;
  11251. break;
  11252. }
  11253. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11254. context.shadowColor = this.shadowColor;
  11255. context.shadowBlur = this.shadowBlur;
  11256. context.shadowOffsetX = this.shadowOffsetX;
  11257. context.shadowOffsetY = this.shadowOffsetY;
  11258. }
  11259. if (this.outlineWidth) {
  11260. context.strokeText(text, this._currentMeasure.left + x, y);
  11261. }
  11262. context.fillText(text, this._currentMeasure.left + x, y);
  11263. };
  11264. /** @hidden */
  11265. TextBlock.prototype._draw = function (context) {
  11266. context.save();
  11267. this._applyStates(context);
  11268. // Render lines
  11269. this._renderLines(context);
  11270. context.restore();
  11271. };
  11272. TextBlock.prototype._applyStates = function (context) {
  11273. _super.prototype._applyStates.call(this, context);
  11274. if (this.outlineWidth) {
  11275. context.lineWidth = this.outlineWidth;
  11276. context.strokeStyle = this.outlineColor;
  11277. }
  11278. };
  11279. TextBlock.prototype._breakLines = function (refWidth, context) {
  11280. var lines = [];
  11281. var _lines = this.text.split("\n");
  11282. if (this._textWrapping === TextWrapping.Ellipsis) {
  11283. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11284. var _line = _lines_1[_i];
  11285. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11286. }
  11287. }
  11288. else if (this._textWrapping === TextWrapping.WordWrap) {
  11289. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11290. var _line = _lines_2[_a];
  11291. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11292. }
  11293. }
  11294. else {
  11295. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11296. var _line = _lines_3[_b];
  11297. lines.push(this._parseLine(_line, context));
  11298. }
  11299. }
  11300. return lines;
  11301. };
  11302. TextBlock.prototype._parseLine = function (line, context) {
  11303. if (line === void 0) { line = ''; }
  11304. return { text: line, width: context.measureText(line).width };
  11305. };
  11306. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11307. if (line === void 0) { line = ''; }
  11308. var lineWidth = context.measureText(line).width;
  11309. if (lineWidth > width) {
  11310. line += '…';
  11311. }
  11312. while (line.length > 2 && lineWidth > width) {
  11313. line = line.slice(0, -2) + '…';
  11314. lineWidth = context.measureText(line).width;
  11315. }
  11316. return { text: line, width: lineWidth };
  11317. };
  11318. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11319. if (line === void 0) { line = ''; }
  11320. var lines = [];
  11321. var words = line.split(' ');
  11322. var lineWidth = 0;
  11323. for (var n = 0; n < words.length; n++) {
  11324. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11325. var metrics = context.measureText(testLine);
  11326. var testWidth = metrics.width;
  11327. if (testWidth > width && n > 0) {
  11328. lines.push({ text: line, width: lineWidth });
  11329. line = words[n];
  11330. lineWidth = context.measureText(line).width;
  11331. }
  11332. else {
  11333. lineWidth = testWidth;
  11334. line = testLine;
  11335. }
  11336. }
  11337. lines.push({ text: line, width: lineWidth });
  11338. return lines;
  11339. };
  11340. TextBlock.prototype._renderLines = function (context) {
  11341. var height = this._currentMeasure.height;
  11342. var rootY = 0;
  11343. switch (this._textVerticalAlignment) {
  11344. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11345. rootY = this._fontOffset.ascent;
  11346. break;
  11347. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11348. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11349. break;
  11350. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11351. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11352. break;
  11353. }
  11354. rootY += this._currentMeasure.top;
  11355. for (var i = 0; i < this._lines.length; i++) {
  11356. var line = this._lines[i];
  11357. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11358. if (this._lineSpacing.isPixel) {
  11359. rootY += this._lineSpacing.getValue(this._host);
  11360. }
  11361. else {
  11362. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11363. }
  11364. }
  11365. this._drawText(line.text, line.width, rootY, context);
  11366. rootY += this._fontOffset.height;
  11367. }
  11368. };
  11369. /**
  11370. * Given a width constraint applied on the text block, find the expected height
  11371. * @returns expected height
  11372. */
  11373. TextBlock.prototype.computeExpectedHeight = function () {
  11374. if (this.text && this.widthInPixels) {
  11375. var context_1 = document.createElement('canvas').getContext('2d');
  11376. if (context_1) {
  11377. this._applyStates(context_1);
  11378. if (!this._fontOffset) {
  11379. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11380. }
  11381. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11382. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11383. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11384. var lineSpacing = 0;
  11385. if (this._lineSpacing.isPixel) {
  11386. lineSpacing = this._lineSpacing.getValue(this._host);
  11387. }
  11388. else {
  11389. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11390. }
  11391. newHeight += (lines.length - 1) * lineSpacing;
  11392. }
  11393. return newHeight;
  11394. }
  11395. }
  11396. return 0;
  11397. };
  11398. TextBlock.prototype.dispose = function () {
  11399. _super.prototype.dispose.call(this);
  11400. this.onTextChangedObservable.clear();
  11401. };
  11402. return TextBlock;
  11403. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11404. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  11405. /***/ }),
  11406. /***/ "./2D/controls/virtualKeyboard.ts":
  11407. /*!****************************************!*\
  11408. !*** ./2D/controls/virtualKeyboard.ts ***!
  11409. \****************************************/
  11410. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11412. "use strict";
  11413. __webpack_require__.r(__webpack_exports__);
  11414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11417. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11418. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11419. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11420. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11421. /**
  11422. * Class used to store key control properties
  11423. */
  11424. var KeyPropertySet = /** @class */ (function () {
  11425. function KeyPropertySet() {
  11426. }
  11427. return KeyPropertySet;
  11428. }());
  11429. /**
  11430. * Class used to create virtual keyboard
  11431. */
  11432. var VirtualKeyboard = /** @class */ (function (_super) {
  11433. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11434. function VirtualKeyboard() {
  11435. var _this = _super !== null && _super.apply(this, arguments) || this;
  11436. /** Observable raised when a key is pressed */
  11437. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11438. /** Gets or sets default key button width */
  11439. _this.defaultButtonWidth = "40px";
  11440. /** Gets or sets default key button height */
  11441. _this.defaultButtonHeight = "40px";
  11442. /** Gets or sets default key button left padding */
  11443. _this.defaultButtonPaddingLeft = "2px";
  11444. /** Gets or sets default key button right padding */
  11445. _this.defaultButtonPaddingRight = "2px";
  11446. /** Gets or sets default key button top padding */
  11447. _this.defaultButtonPaddingTop = "2px";
  11448. /** Gets or sets default key button bottom padding */
  11449. _this.defaultButtonPaddingBottom = "2px";
  11450. /** Gets or sets default key button foreground color */
  11451. _this.defaultButtonColor = "#DDD";
  11452. /** Gets or sets default key button background color */
  11453. _this.defaultButtonBackground = "#070707";
  11454. /** Gets or sets shift button foreground color */
  11455. _this.shiftButtonColor = "#7799FF";
  11456. /** Gets or sets shift button thickness*/
  11457. _this.selectedShiftThickness = 1;
  11458. /** Gets shift key state */
  11459. _this.shiftState = 0;
  11460. _this._currentlyConnectedInputText = null;
  11461. _this._connectedInputTexts = [];
  11462. _this._onKeyPressObserver = null;
  11463. return _this;
  11464. }
  11465. VirtualKeyboard.prototype._getTypeName = function () {
  11466. return "VirtualKeyboard";
  11467. };
  11468. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11469. var _this = this;
  11470. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11471. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11472. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11473. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11474. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11475. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11476. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11477. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11478. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11479. button.thickness = 0;
  11480. button.isFocusInvisible = true;
  11481. button.shadowColor = this.shadowColor;
  11482. button.shadowBlur = this.shadowBlur;
  11483. button.shadowOffsetX = this.shadowOffsetX;
  11484. button.shadowOffsetY = this.shadowOffsetY;
  11485. button.onPointerUpObservable.add(function () {
  11486. _this.onKeyPressObservable.notifyObservers(key);
  11487. });
  11488. return button;
  11489. };
  11490. /**
  11491. * Adds a new row of keys
  11492. * @param keys defines the list of keys to add
  11493. * @param propertySets defines the associated property sets
  11494. */
  11495. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11496. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11497. panel.isVertical = false;
  11498. panel.isFocusInvisible = true;
  11499. var maxKey = null;
  11500. for (var i = 0; i < keys.length; i++) {
  11501. var properties = null;
  11502. if (propertySets && propertySets.length === keys.length) {
  11503. properties = propertySets[i];
  11504. }
  11505. var key = this._createKey(keys[i], properties);
  11506. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11507. maxKey = key;
  11508. }
  11509. panel.addControl(key);
  11510. }
  11511. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11512. this.addControl(panel);
  11513. };
  11514. /**
  11515. * Set the shift key to a specific state
  11516. * @param shiftState defines the new shift state
  11517. */
  11518. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11519. if (!this.children) {
  11520. return;
  11521. }
  11522. for (var i = 0; i < this.children.length; i++) {
  11523. var row = this.children[i];
  11524. if (!row || !row.children) {
  11525. continue;
  11526. }
  11527. var rowContainer = row;
  11528. for (var j = 0; j < rowContainer.children.length; j++) {
  11529. var button = rowContainer.children[j];
  11530. if (!button || !button.children[0]) {
  11531. continue;
  11532. }
  11533. var button_tblock = button.children[0];
  11534. if (button_tblock.text === "\u21E7") {
  11535. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11536. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11537. }
  11538. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11539. }
  11540. }
  11541. };
  11542. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11543. /** Gets the input text control currently attached to the keyboard */
  11544. get: function () {
  11545. return this._currentlyConnectedInputText;
  11546. },
  11547. enumerable: true,
  11548. configurable: true
  11549. });
  11550. /**
  11551. * Connects the keyboard with an input text control
  11552. *
  11553. * @param input defines the target control
  11554. */
  11555. VirtualKeyboard.prototype.connect = function (input) {
  11556. var _this = this;
  11557. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11558. if (inputTextAlreadyConnected) {
  11559. return;
  11560. }
  11561. if (this._onKeyPressObserver === null) {
  11562. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11563. if (!_this._currentlyConnectedInputText) {
  11564. return;
  11565. }
  11566. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11567. switch (key) {
  11568. case "\u21E7":
  11569. _this.shiftState++;
  11570. if (_this.shiftState > 2) {
  11571. _this.shiftState = 0;
  11572. }
  11573. _this.applyShiftState(_this.shiftState);
  11574. return;
  11575. case "\u2190":
  11576. _this._currentlyConnectedInputText.processKey(8);
  11577. return;
  11578. case "\u21B5":
  11579. _this._currentlyConnectedInputText.processKey(13);
  11580. return;
  11581. }
  11582. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11583. if (_this.shiftState === 1) {
  11584. _this.shiftState = 0;
  11585. _this.applyShiftState(_this.shiftState);
  11586. }
  11587. });
  11588. }
  11589. this.isVisible = false;
  11590. this._currentlyConnectedInputText = input;
  11591. input._connectedVirtualKeyboard = this;
  11592. // Events hooking
  11593. var onFocusObserver = input.onFocusObservable.add(function () {
  11594. _this._currentlyConnectedInputText = input;
  11595. input._connectedVirtualKeyboard = _this;
  11596. _this.isVisible = true;
  11597. });
  11598. var onBlurObserver = input.onBlurObservable.add(function () {
  11599. input._connectedVirtualKeyboard = null;
  11600. _this._currentlyConnectedInputText = null;
  11601. _this.isVisible = false;
  11602. });
  11603. this._connectedInputTexts.push({
  11604. input: input,
  11605. onBlurObserver: onBlurObserver,
  11606. onFocusObserver: onFocusObserver
  11607. });
  11608. };
  11609. /**
  11610. * Disconnects the keyboard from connected InputText controls
  11611. *
  11612. * @param input optionally defines a target control, otherwise all are disconnected
  11613. */
  11614. VirtualKeyboard.prototype.disconnect = function (input) {
  11615. var _this = this;
  11616. if (input) {
  11617. // .find not available on IE
  11618. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11619. if (filtered.length === 1) {
  11620. this._removeConnectedInputObservables(filtered[0]);
  11621. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11622. if (this._currentlyConnectedInputText === input) {
  11623. this._currentlyConnectedInputText = null;
  11624. }
  11625. }
  11626. }
  11627. else {
  11628. this._connectedInputTexts.forEach(function (connectedInputText) {
  11629. _this._removeConnectedInputObservables(connectedInputText);
  11630. });
  11631. this._connectedInputTexts = [];
  11632. }
  11633. if (this._connectedInputTexts.length === 0) {
  11634. this._currentlyConnectedInputText = null;
  11635. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11636. this._onKeyPressObserver = null;
  11637. }
  11638. };
  11639. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11640. connectedInputText.input._connectedVirtualKeyboard = null;
  11641. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11642. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11643. };
  11644. /**
  11645. * Release all resources
  11646. */
  11647. VirtualKeyboard.prototype.dispose = function () {
  11648. _super.prototype.dispose.call(this);
  11649. this.disconnect();
  11650. };
  11651. // Statics
  11652. /**
  11653. * Creates a new keyboard using a default layout
  11654. *
  11655. * @param name defines control name
  11656. * @returns a new VirtualKeyboard
  11657. */
  11658. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11659. var returnValue = new VirtualKeyboard(name);
  11660. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11661. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11662. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11663. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11664. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11665. return returnValue;
  11666. };
  11667. return VirtualKeyboard;
  11668. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11669. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  11670. /***/ }),
  11671. /***/ "./2D/index.ts":
  11672. /*!*********************!*\
  11673. !*** ./2D/index.ts ***!
  11674. \*********************/
  11675. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, 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, name */
  11676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11677. "use strict";
  11678. __webpack_require__.r(__webpack_exports__);
  11679. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11711. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11713. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11715. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11718. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11720. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11722. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11724. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11726. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  11727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  11728. /***/ }),
  11729. /***/ "./2D/math2D.ts":
  11730. /*!**********************!*\
  11731. !*** ./2D/math2D.ts ***!
  11732. \**********************/
  11733. /*! exports provided: Vector2WithInfo, Matrix2D */
  11734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11735. "use strict";
  11736. __webpack_require__.r(__webpack_exports__);
  11737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11740. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11741. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11742. /**
  11743. * Class used to transport Vector2 information for pointer events
  11744. */
  11745. var Vector2WithInfo = /** @class */ (function (_super) {
  11746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11747. /**
  11748. * Creates a new Vector2WithInfo
  11749. * @param source defines the vector2 data to transport
  11750. * @param buttonIndex defines the current mouse button index
  11751. */
  11752. function Vector2WithInfo(source,
  11753. /** defines the current mouse button index */
  11754. buttonIndex) {
  11755. if (buttonIndex === void 0) { buttonIndex = 0; }
  11756. var _this = _super.call(this, source.x, source.y) || this;
  11757. _this.buttonIndex = buttonIndex;
  11758. return _this;
  11759. }
  11760. return Vector2WithInfo;
  11761. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11762. /** Class used to provide 2D matrix features */
  11763. var Matrix2D = /** @class */ (function () {
  11764. /**
  11765. * Creates a new matrix
  11766. * @param m00 defines value for (0, 0)
  11767. * @param m01 defines value for (0, 1)
  11768. * @param m10 defines value for (1, 0)
  11769. * @param m11 defines value for (1, 1)
  11770. * @param m20 defines value for (2, 0)
  11771. * @param m21 defines value for (2, 1)
  11772. */
  11773. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11774. /** Gets the internal array of 6 floats used to store matrix data */
  11775. this.m = new Float32Array(6);
  11776. this.fromValues(m00, m01, m10, m11, m20, m21);
  11777. }
  11778. /**
  11779. * Fills the matrix from direct values
  11780. * @param m00 defines value for (0, 0)
  11781. * @param m01 defines value for (0, 1)
  11782. * @param m10 defines value for (1, 0)
  11783. * @param m11 defines value for (1, 1)
  11784. * @param m20 defines value for (2, 0)
  11785. * @param m21 defines value for (2, 1)
  11786. * @returns the current modified matrix
  11787. */
  11788. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11789. this.m[0] = m00;
  11790. this.m[1] = m01;
  11791. this.m[2] = m10;
  11792. this.m[3] = m11;
  11793. this.m[4] = m20;
  11794. this.m[5] = m21;
  11795. return this;
  11796. };
  11797. /**
  11798. * Gets matrix determinant
  11799. * @returns the determinant
  11800. */
  11801. Matrix2D.prototype.determinant = function () {
  11802. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11803. };
  11804. /**
  11805. * Inverses the matrix and stores it in a target matrix
  11806. * @param result defines the target matrix
  11807. * @returns the current matrix
  11808. */
  11809. Matrix2D.prototype.invertToRef = function (result) {
  11810. var l0 = this.m[0];
  11811. var l1 = this.m[1];
  11812. var l2 = this.m[2];
  11813. var l3 = this.m[3];
  11814. var l4 = this.m[4];
  11815. var l5 = this.m[5];
  11816. var det = this.determinant();
  11817. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11818. result.m[0] = 0;
  11819. result.m[1] = 0;
  11820. result.m[2] = 0;
  11821. result.m[3] = 0;
  11822. result.m[4] = 0;
  11823. result.m[5] = 0;
  11824. return this;
  11825. }
  11826. var detDiv = 1 / det;
  11827. var det4 = l2 * l5 - l3 * l4;
  11828. var det5 = l1 * l4 - l0 * l5;
  11829. result.m[0] = l3 * detDiv;
  11830. result.m[1] = -l1 * detDiv;
  11831. result.m[2] = -l2 * detDiv;
  11832. result.m[3] = l0 * detDiv;
  11833. result.m[4] = det4 * detDiv;
  11834. result.m[5] = det5 * detDiv;
  11835. return this;
  11836. };
  11837. /**
  11838. * Multiplies the current matrix with another one
  11839. * @param other defines the second operand
  11840. * @param result defines the target matrix
  11841. * @returns the current matrix
  11842. */
  11843. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11844. var l0 = this.m[0];
  11845. var l1 = this.m[1];
  11846. var l2 = this.m[2];
  11847. var l3 = this.m[3];
  11848. var l4 = this.m[4];
  11849. var l5 = this.m[5];
  11850. var r0 = other.m[0];
  11851. var r1 = other.m[1];
  11852. var r2 = other.m[2];
  11853. var r3 = other.m[3];
  11854. var r4 = other.m[4];
  11855. var r5 = other.m[5];
  11856. result.m[0] = l0 * r0 + l1 * r2;
  11857. result.m[1] = l0 * r1 + l1 * r3;
  11858. result.m[2] = l2 * r0 + l3 * r2;
  11859. result.m[3] = l2 * r1 + l3 * r3;
  11860. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11861. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11862. return this;
  11863. };
  11864. /**
  11865. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11866. * @param x defines the x coordinate to transform
  11867. * @param y defines the x coordinate to transform
  11868. * @param result defines the target vector2
  11869. * @returns the current matrix
  11870. */
  11871. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11872. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11873. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11874. return this;
  11875. };
  11876. // Statics
  11877. /**
  11878. * Creates an identity matrix
  11879. * @returns a new matrix
  11880. */
  11881. Matrix2D.Identity = function () {
  11882. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11883. };
  11884. /**
  11885. * Creates a translation matrix and stores it in a target matrix
  11886. * @param x defines the x coordinate of the translation
  11887. * @param y defines the y coordinate of the translation
  11888. * @param result defines the target matrix
  11889. */
  11890. Matrix2D.TranslationToRef = function (x, y, result) {
  11891. result.fromValues(1, 0, 0, 1, x, y);
  11892. };
  11893. /**
  11894. * Creates a scaling matrix and stores it in a target matrix
  11895. * @param x defines the x coordinate of the scaling
  11896. * @param y defines the y coordinate of the scaling
  11897. * @param result defines the target matrix
  11898. */
  11899. Matrix2D.ScalingToRef = function (x, y, result) {
  11900. result.fromValues(x, 0, 0, y, 0, 0);
  11901. };
  11902. /**
  11903. * Creates a rotation matrix and stores it in a target matrix
  11904. * @param angle defines the rotation angle
  11905. * @param result defines the target matrix
  11906. */
  11907. Matrix2D.RotationToRef = function (angle, result) {
  11908. var s = Math.sin(angle);
  11909. var c = Math.cos(angle);
  11910. result.fromValues(c, s, -s, c, 0, 0);
  11911. };
  11912. /**
  11913. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11914. * @param tx defines the x coordinate of the translation
  11915. * @param ty defines the y coordinate of the translation
  11916. * @param angle defines the rotation angle
  11917. * @param scaleX defines the x coordinate of the scaling
  11918. * @param scaleY defines the y coordinate of the scaling
  11919. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11920. * @param result defines the target matrix
  11921. */
  11922. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11923. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11924. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11925. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11926. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11927. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11928. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11929. if (parentMatrix) {
  11930. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11931. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11932. }
  11933. else {
  11934. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11935. }
  11936. };
  11937. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11938. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11939. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11940. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11941. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11942. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11943. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11944. return Matrix2D;
  11945. }());
  11946. /***/ }),
  11947. /***/ "./2D/measure.ts":
  11948. /*!***********************!*\
  11949. !*** ./2D/measure.ts ***!
  11950. \***********************/
  11951. /*! exports provided: Measure */
  11952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11953. "use strict";
  11954. __webpack_require__.r(__webpack_exports__);
  11955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11956. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11957. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11958. /**
  11959. * Class used to store 2D control sizes
  11960. */
  11961. var Measure = /** @class */ (function () {
  11962. /**
  11963. * Creates a new measure
  11964. * @param left defines left coordinate
  11965. * @param top defines top coordinate
  11966. * @param width defines width dimension
  11967. * @param height defines height dimension
  11968. */
  11969. function Measure(
  11970. /** defines left coordinate */
  11971. left,
  11972. /** defines top coordinate */
  11973. top,
  11974. /** defines width dimension */
  11975. width,
  11976. /** defines height dimension */
  11977. height) {
  11978. this.left = left;
  11979. this.top = top;
  11980. this.width = width;
  11981. this.height = height;
  11982. }
  11983. /**
  11984. * Copy from another measure
  11985. * @param other defines the other measure to copy from
  11986. */
  11987. Measure.prototype.copyFrom = function (other) {
  11988. this.left = other.left;
  11989. this.top = other.top;
  11990. this.width = other.width;
  11991. this.height = other.height;
  11992. };
  11993. /**
  11994. * Copy from a group of 4 floats
  11995. * @param left defines left coordinate
  11996. * @param top defines top coordinate
  11997. * @param width defines width dimension
  11998. * @param height defines height dimension
  11999. */
  12000. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12001. this.left = left;
  12002. this.top = top;
  12003. this.width = width;
  12004. this.height = height;
  12005. };
  12006. /**
  12007. * Computes the axis aligned bounding box measure for two given measures
  12008. * @param a Input measure
  12009. * @param b Input measure
  12010. * @param result the resulting bounding measure
  12011. */
  12012. Measure.CombineToRef = function (a, b, result) {
  12013. var left = Math.min(a.left, b.left);
  12014. var top = Math.min(a.top, b.top);
  12015. var right = Math.max(a.left + a.width, b.left + b.width);
  12016. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12017. result.left = left;
  12018. result.top = top;
  12019. result.width = right - left;
  12020. result.height = bottom - top;
  12021. };
  12022. /**
  12023. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12024. * @param transform the matrix to transform the measure before computing the AABB
  12025. * @param result the resulting AABB
  12026. */
  12027. Measure.prototype.transformToRef = function (transform, result) {
  12028. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  12029. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  12030. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12031. for (var i = 0; i < 4; i++) {
  12032. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  12033. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  12034. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  12035. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  12036. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12037. }
  12038. result.left = min.x;
  12039. result.top = min.y;
  12040. result.width = max.x - min.x;
  12041. result.height = max.y - min.y;
  12042. };
  12043. /**
  12044. * Check equality between this measure and another one
  12045. * @param other defines the other measures
  12046. * @returns true if both measures are equals
  12047. */
  12048. Measure.prototype.isEqualsTo = function (other) {
  12049. if (this.left !== other.left) {
  12050. return false;
  12051. }
  12052. if (this.top !== other.top) {
  12053. return false;
  12054. }
  12055. if (this.width !== other.width) {
  12056. return false;
  12057. }
  12058. if (this.height !== other.height) {
  12059. return false;
  12060. }
  12061. return true;
  12062. };
  12063. /**
  12064. * Creates an empty measure
  12065. * @returns a new measure
  12066. */
  12067. Measure.Empty = function () {
  12068. return new Measure(0, 0, 0, 0);
  12069. };
  12070. return Measure;
  12071. }());
  12072. /***/ }),
  12073. /***/ "./2D/multiLinePoint.ts":
  12074. /*!******************************!*\
  12075. !*** ./2D/multiLinePoint.ts ***!
  12076. \******************************/
  12077. /*! exports provided: MultiLinePoint */
  12078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12079. "use strict";
  12080. __webpack_require__.r(__webpack_exports__);
  12081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12082. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12083. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12084. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12085. /**
  12086. * Class used to store a point for a MultiLine object.
  12087. * The point can be pure 2D coordinates, a mesh or a control
  12088. */
  12089. var MultiLinePoint = /** @class */ (function () {
  12090. /**
  12091. * Creates a new MultiLinePoint
  12092. * @param multiLine defines the source MultiLine object
  12093. */
  12094. function MultiLinePoint(multiLine) {
  12095. this._multiLine = multiLine;
  12096. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12097. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12098. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12099. }
  12100. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12101. /** Gets or sets x coordinate */
  12102. get: function () {
  12103. return this._x.toString(this._multiLine._host);
  12104. },
  12105. set: function (value) {
  12106. if (this._x.toString(this._multiLine._host) === value) {
  12107. return;
  12108. }
  12109. if (this._x.fromString(value)) {
  12110. this._multiLine._markAsDirty();
  12111. }
  12112. },
  12113. enumerable: true,
  12114. configurable: true
  12115. });
  12116. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12117. /** Gets or sets y coordinate */
  12118. get: function () {
  12119. return this._y.toString(this._multiLine._host);
  12120. },
  12121. set: function (value) {
  12122. if (this._y.toString(this._multiLine._host) === value) {
  12123. return;
  12124. }
  12125. if (this._y.fromString(value)) {
  12126. this._multiLine._markAsDirty();
  12127. }
  12128. },
  12129. enumerable: true,
  12130. configurable: true
  12131. });
  12132. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12133. /** Gets or sets the control associated with this point */
  12134. get: function () {
  12135. return this._control;
  12136. },
  12137. set: function (value) {
  12138. if (this._control === value) {
  12139. return;
  12140. }
  12141. if (this._control && this._controlObserver) {
  12142. this._control.onDirtyObservable.remove(this._controlObserver);
  12143. this._controlObserver = null;
  12144. }
  12145. this._control = value;
  12146. if (this._control) {
  12147. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12148. }
  12149. this._multiLine._markAsDirty();
  12150. },
  12151. enumerable: true,
  12152. configurable: true
  12153. });
  12154. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12155. /** Gets or sets the mesh associated with this point */
  12156. get: function () {
  12157. return this._mesh;
  12158. },
  12159. set: function (value) {
  12160. if (this._mesh === value) {
  12161. return;
  12162. }
  12163. if (this._mesh && this._meshObserver) {
  12164. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12165. }
  12166. this._mesh = value;
  12167. if (this._mesh) {
  12168. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12169. }
  12170. this._multiLine._markAsDirty();
  12171. },
  12172. enumerable: true,
  12173. configurable: true
  12174. });
  12175. /** Resets links */
  12176. MultiLinePoint.prototype.resetLinks = function () {
  12177. this.control = null;
  12178. this.mesh = null;
  12179. };
  12180. /**
  12181. * Gets a translation vector
  12182. * @returns the translation vector
  12183. */
  12184. MultiLinePoint.prototype.translate = function () {
  12185. this._point = this._translatePoint();
  12186. return this._point;
  12187. };
  12188. MultiLinePoint.prototype._translatePoint = function () {
  12189. if (this._mesh != null) {
  12190. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12191. }
  12192. else if (this._control != null) {
  12193. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12194. }
  12195. else {
  12196. var host = this._multiLine._host;
  12197. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12198. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12199. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12200. }
  12201. };
  12202. /** Release associated resources */
  12203. MultiLinePoint.prototype.dispose = function () {
  12204. this.resetLinks();
  12205. };
  12206. return MultiLinePoint;
  12207. }());
  12208. /***/ }),
  12209. /***/ "./2D/style.ts":
  12210. /*!*********************!*\
  12211. !*** ./2D/style.ts ***!
  12212. \*********************/
  12213. /*! exports provided: Style */
  12214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12215. "use strict";
  12216. __webpack_require__.r(__webpack_exports__);
  12217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12218. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12219. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12220. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12221. /**
  12222. * Define a style used by control to automatically setup properties based on a template.
  12223. * Only support font related properties so far
  12224. */
  12225. var Style = /** @class */ (function () {
  12226. /**
  12227. * Creates a new style object
  12228. * @param host defines the AdvancedDynamicTexture which hosts this style
  12229. */
  12230. function Style(host) {
  12231. this._fontFamily = "Arial";
  12232. this._fontStyle = "";
  12233. this._fontWeight = "";
  12234. /** @hidden */
  12235. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12236. /**
  12237. * Observable raised when the style values are changed
  12238. */
  12239. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12240. this._host = host;
  12241. }
  12242. Object.defineProperty(Style.prototype, "fontSize", {
  12243. /**
  12244. * Gets or sets the font size
  12245. */
  12246. get: function () {
  12247. return this._fontSize.toString(this._host);
  12248. },
  12249. set: function (value) {
  12250. if (this._fontSize.toString(this._host) === value) {
  12251. return;
  12252. }
  12253. if (this._fontSize.fromString(value)) {
  12254. this.onChangedObservable.notifyObservers(this);
  12255. }
  12256. },
  12257. enumerable: true,
  12258. configurable: true
  12259. });
  12260. Object.defineProperty(Style.prototype, "fontFamily", {
  12261. /**
  12262. * Gets or sets the font family
  12263. */
  12264. get: function () {
  12265. return this._fontFamily;
  12266. },
  12267. set: function (value) {
  12268. if (this._fontFamily === value) {
  12269. return;
  12270. }
  12271. this._fontFamily = value;
  12272. this.onChangedObservable.notifyObservers(this);
  12273. },
  12274. enumerable: true,
  12275. configurable: true
  12276. });
  12277. Object.defineProperty(Style.prototype, "fontStyle", {
  12278. /**
  12279. * Gets or sets the font style
  12280. */
  12281. get: function () {
  12282. return this._fontStyle;
  12283. },
  12284. set: function (value) {
  12285. if (this._fontStyle === value) {
  12286. return;
  12287. }
  12288. this._fontStyle = value;
  12289. this.onChangedObservable.notifyObservers(this);
  12290. },
  12291. enumerable: true,
  12292. configurable: true
  12293. });
  12294. Object.defineProperty(Style.prototype, "fontWeight", {
  12295. /** Gets or sets font weight */
  12296. get: function () {
  12297. return this._fontWeight;
  12298. },
  12299. set: function (value) {
  12300. if (this._fontWeight === value) {
  12301. return;
  12302. }
  12303. this._fontWeight = value;
  12304. this.onChangedObservable.notifyObservers(this);
  12305. },
  12306. enumerable: true,
  12307. configurable: true
  12308. });
  12309. /** Dispose all associated resources */
  12310. Style.prototype.dispose = function () {
  12311. this.onChangedObservable.clear();
  12312. };
  12313. return Style;
  12314. }());
  12315. /***/ }),
  12316. /***/ "./2D/valueAndUnit.ts":
  12317. /*!****************************!*\
  12318. !*** ./2D/valueAndUnit.ts ***!
  12319. \****************************/
  12320. /*! exports provided: ValueAndUnit */
  12321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12322. "use strict";
  12323. __webpack_require__.r(__webpack_exports__);
  12324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12325. /**
  12326. * Class used to specific a value and its associated unit
  12327. */
  12328. var ValueAndUnit = /** @class */ (function () {
  12329. /**
  12330. * Creates a new ValueAndUnit
  12331. * @param value defines the value to store
  12332. * @param unit defines the unit to store
  12333. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12334. */
  12335. function ValueAndUnit(value,
  12336. /** defines the unit to store */
  12337. unit,
  12338. /** defines a boolean indicating if the value can be negative */
  12339. negativeValueAllowed) {
  12340. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12341. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12342. this.unit = unit;
  12343. this.negativeValueAllowed = negativeValueAllowed;
  12344. this._value = 1;
  12345. /**
  12346. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12347. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12348. */
  12349. this.ignoreAdaptiveScaling = false;
  12350. this._value = value;
  12351. this._originalUnit = unit;
  12352. }
  12353. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12354. /** Gets a boolean indicating if the value is a percentage */
  12355. get: function () {
  12356. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12357. },
  12358. enumerable: true,
  12359. configurable: true
  12360. });
  12361. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12362. /** Gets a boolean indicating if the value is store as pixel */
  12363. get: function () {
  12364. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12365. },
  12366. enumerable: true,
  12367. configurable: true
  12368. });
  12369. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12370. /** Gets direct internal value */
  12371. get: function () {
  12372. return this._value;
  12373. },
  12374. enumerable: true,
  12375. configurable: true
  12376. });
  12377. /**
  12378. * Gets value as pixel
  12379. * @param host defines the root host
  12380. * @param refValue defines the reference value for percentages
  12381. * @returns the value as pixel
  12382. */
  12383. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12384. if (this.isPixel) {
  12385. return this.getValue(host);
  12386. }
  12387. return this.getValue(host) * refValue;
  12388. };
  12389. /**
  12390. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12391. * @param value defines the value to store
  12392. * @param unit defines the unit to store
  12393. * @returns the current ValueAndUnit
  12394. */
  12395. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12396. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12397. this._value = value;
  12398. this.unit = unit;
  12399. return this;
  12400. };
  12401. /**
  12402. * Gets the value accordingly to its unit
  12403. * @param host defines the root host
  12404. * @returns the value
  12405. */
  12406. ValueAndUnit.prototype.getValue = function (host) {
  12407. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12408. var width = 0;
  12409. var height = 0;
  12410. if (host.idealWidth) {
  12411. width = (this._value * host.getSize().width) / host.idealWidth;
  12412. }
  12413. if (host.idealHeight) {
  12414. height = (this._value * host.getSize().height) / host.idealHeight;
  12415. }
  12416. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12417. return window.innerWidth < window.innerHeight ? width : height;
  12418. }
  12419. if (host.idealWidth) { // horizontal
  12420. return width;
  12421. }
  12422. if (host.idealHeight) { // vertical
  12423. return height;
  12424. }
  12425. }
  12426. return this._value;
  12427. };
  12428. /**
  12429. * Gets a string representation of the value
  12430. * @param host defines the root host
  12431. * @param decimals defines an optional number of decimals to display
  12432. * @returns a string
  12433. */
  12434. ValueAndUnit.prototype.toString = function (host, decimals) {
  12435. switch (this.unit) {
  12436. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12437. var percentage = this.getValue(host) * 100;
  12438. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12439. case ValueAndUnit.UNITMODE_PIXEL:
  12440. var pixels = this.getValue(host);
  12441. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12442. }
  12443. return this.unit.toString();
  12444. };
  12445. /**
  12446. * Store a value parsed from a string
  12447. * @param source defines the source string
  12448. * @returns true if the value was successfully parsed
  12449. */
  12450. ValueAndUnit.prototype.fromString = function (source) {
  12451. var match = ValueAndUnit._Regex.exec(source.toString());
  12452. if (!match || match.length === 0) {
  12453. return false;
  12454. }
  12455. var sourceValue = parseFloat(match[1]);
  12456. var sourceUnit = this._originalUnit;
  12457. if (!this.negativeValueAllowed) {
  12458. if (sourceValue < 0) {
  12459. sourceValue = 0;
  12460. }
  12461. }
  12462. if (match.length === 4) {
  12463. switch (match[3]) {
  12464. case "px":
  12465. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12466. break;
  12467. case "%":
  12468. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12469. sourceValue /= 100.0;
  12470. break;
  12471. }
  12472. }
  12473. if (sourceValue === this._value && sourceUnit === this.unit) {
  12474. return false;
  12475. }
  12476. this._value = sourceValue;
  12477. this.unit = sourceUnit;
  12478. return true;
  12479. };
  12480. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12481. /** UNITMODE_PERCENTAGE */
  12482. get: function () {
  12483. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12484. },
  12485. enumerable: true,
  12486. configurable: true
  12487. });
  12488. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12489. /** UNITMODE_PIXEL */
  12490. get: function () {
  12491. return ValueAndUnit._UNITMODE_PIXEL;
  12492. },
  12493. enumerable: true,
  12494. configurable: true
  12495. });
  12496. // Static
  12497. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12498. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12499. ValueAndUnit._UNITMODE_PIXEL = 1;
  12500. return ValueAndUnit;
  12501. }());
  12502. /***/ }),
  12503. /***/ "./2D/xmlLoader.ts":
  12504. /*!*************************!*\
  12505. !*** ./2D/xmlLoader.ts ***!
  12506. \*************************/
  12507. /*! exports provided: XmlLoader */
  12508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12509. "use strict";
  12510. __webpack_require__.r(__webpack_exports__);
  12511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  12512. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  12513. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  12514. /**
  12515. * Class used to load GUI via XML.
  12516. */
  12517. var XmlLoader = /** @class */ (function () {
  12518. /**
  12519. * Create a new xml loader
  12520. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  12521. */
  12522. function XmlLoader(parentClass) {
  12523. if (parentClass === void 0) { parentClass = null; }
  12524. this._nodes = {};
  12525. this._nodeTypes = {
  12526. element: 1,
  12527. attribute: 2,
  12528. text: 3
  12529. };
  12530. this._isLoaded = false;
  12531. this._objectAttributes = {
  12532. "textHorizontalAlignment": 1,
  12533. "textVerticalAlignment": 2,
  12534. "horizontalAlignment": 3,
  12535. "verticalAlignment": 4,
  12536. "stretch": 5,
  12537. };
  12538. if (parentClass) {
  12539. this._parentClass = parentClass;
  12540. }
  12541. }
  12542. XmlLoader.prototype._getChainElement = function (attributeValue) {
  12543. var element = window;
  12544. if (this._parentClass) {
  12545. element = this._parentClass;
  12546. }
  12547. var value = attributeValue;
  12548. value = value.split(".");
  12549. for (var i = 0; i < value.length; i++) {
  12550. element = element[value[i]];
  12551. }
  12552. return element;
  12553. };
  12554. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  12555. var attribute = attributeName.split(".");
  12556. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  12557. return className[attribute[1]];
  12558. };
  12559. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  12560. if (linkParent === void 0) { linkParent = true; }
  12561. try {
  12562. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  12563. var guiNode = new className();
  12564. if (parent && linkParent) {
  12565. parent.addControl(guiNode);
  12566. }
  12567. for (var i = 0; i < node.attributes.length; i++) {
  12568. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  12569. continue;
  12570. }
  12571. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  12572. var element = this._getChainElement(node.attributes[i].value);
  12573. guiNode[node.attributes[i].name].add(element);
  12574. continue;
  12575. }
  12576. else if (node.attributes[i].name == "linkWithMesh") {
  12577. if (this._parentClass) {
  12578. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  12579. }
  12580. else {
  12581. guiNode.linkWithMesh(window[node.attributes[i].value]);
  12582. }
  12583. }
  12584. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  12585. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  12586. guiNode[node.attributes[i].name] = element;
  12587. }
  12588. else if (!this._objectAttributes[node.attributes[i].name]) {
  12589. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  12590. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  12591. }
  12592. else {
  12593. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  12594. }
  12595. }
  12596. else {
  12597. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  12598. }
  12599. }
  12600. if (!node.attributes.getNamedItem("id")) {
  12601. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  12602. return guiNode;
  12603. }
  12604. if (!this._nodes[node.attributes.getNamedItem("id").nodeValue]) {
  12605. this._nodes[node.attributes.getNamedItem("id").nodeValue] = guiNode;
  12606. }
  12607. else {
  12608. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  12609. }
  12610. return guiNode;
  12611. }
  12612. catch (e) {
  12613. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  12614. }
  12615. };
  12616. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  12617. var width;
  12618. var height;
  12619. var columns;
  12620. var rows = node.children;
  12621. var cells;
  12622. var isPixel = false;
  12623. var cellNode;
  12624. var rowNumber = -1;
  12625. var columnNumber = -1;
  12626. var totalColumnsNumber = 0;
  12627. for (var i = 0; i < rows.length; i++) {
  12628. if (rows[i].nodeType != this._nodeTypes.element) {
  12629. continue;
  12630. }
  12631. if (rows[i].nodeName != "Row") {
  12632. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  12633. }
  12634. rowNumber += 1;
  12635. columns = rows[i].children;
  12636. if (!rows[i].attributes.getNamedItem("height")) {
  12637. throw "XmlLoader Exception : Height must be defined for grid rows";
  12638. }
  12639. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  12640. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  12641. guiNode.addRowDefinition(height, isPixel);
  12642. for (var j = 0; j < columns.length; j++) {
  12643. if (columns[j].nodeType != this._nodeTypes.element) {
  12644. continue;
  12645. }
  12646. if (columns[j].nodeName != "Column") {
  12647. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  12648. }
  12649. columnNumber += 1;
  12650. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  12651. 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.";
  12652. }
  12653. if (rowNumber == 0) {
  12654. if (!columns[j].attributes.getNamedItem("width")) {
  12655. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  12656. }
  12657. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  12658. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  12659. guiNode.addColumnDefinition(width, isPixel);
  12660. }
  12661. cells = columns[j].children;
  12662. for (var k = 0; k < cells.length; k++) {
  12663. if (cells[k].nodeType != this._nodeTypes.element) {
  12664. continue;
  12665. }
  12666. cellNode = this._createGuiElement(cells[k], guiNode, false);
  12667. guiNode.addControl(cellNode, rowNumber, columnNumber);
  12668. if (cells[k].firstChild) {
  12669. this._parseXml(cells[k].firstChild, cellNode);
  12670. }
  12671. }
  12672. }
  12673. if (rowNumber == 0) {
  12674. totalColumnsNumber = columnNumber;
  12675. }
  12676. columnNumber = -1;
  12677. }
  12678. if (node.nextSibling) {
  12679. this._parseXml(node.nextSibling, parent);
  12680. }
  12681. };
  12682. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  12683. if (node.firstChild) {
  12684. this._parseXml(node.firstChild, guiNode);
  12685. }
  12686. if (node.nextSibling) {
  12687. this._parseXml(node.nextSibling, parent);
  12688. }
  12689. };
  12690. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  12691. if (this._parentClass) {
  12692. this._parentClass[variable] = source[iterator];
  12693. }
  12694. else {
  12695. window[variable] = source[iterator];
  12696. }
  12697. if (node.firstChild) {
  12698. this._parseXml(node.firstChild, guiNode, true);
  12699. }
  12700. };
  12701. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  12702. var dataSource = node.attributes.getNamedItem("dataSource").value;
  12703. if (!dataSource.includes(" in ")) {
  12704. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  12705. }
  12706. else {
  12707. var isArray = true;
  12708. var splittedSource = dataSource.split(" in ");
  12709. if (splittedSource.length < 2) {
  12710. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  12711. }
  12712. var source = splittedSource[1];
  12713. if (source.startsWith("{") && source.endsWith("}")) {
  12714. isArray = false;
  12715. }
  12716. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  12717. source = source.substring(1, source.length - 1);
  12718. }
  12719. if (this._parentClass) {
  12720. source = this._parentClass[source];
  12721. }
  12722. else {
  12723. source = window[source];
  12724. }
  12725. if (isArray) {
  12726. for (var i = 0; i < source.length; i++) {
  12727. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  12728. }
  12729. }
  12730. else {
  12731. for (var i in source) {
  12732. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  12733. }
  12734. }
  12735. if (node.nextSibling) {
  12736. this._parseXml(node.nextSibling, parent);
  12737. }
  12738. }
  12739. };
  12740. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  12741. if (generated === void 0) { generated = false; }
  12742. if (node.nodeType != this._nodeTypes.element) {
  12743. if (node.nextSibling) {
  12744. this._parseXml(node.nextSibling, parent, generated);
  12745. }
  12746. return;
  12747. }
  12748. if (generated) {
  12749. node.setAttribute("id", parent.id + parent._children.length + 1);
  12750. }
  12751. var guiNode = this._createGuiElement(node, parent);
  12752. if (node.nodeName == "Grid") {
  12753. this._parseGrid(node, guiNode, parent);
  12754. }
  12755. else if (!node.attributes.getNamedItem("dataSource")) {
  12756. this._parseElement(node, guiNode, parent);
  12757. }
  12758. else {
  12759. this._parseElementsFromSource(node, guiNode, parent);
  12760. }
  12761. };
  12762. /**
  12763. * Gets if the loading has finished.
  12764. * @returns whether the loading has finished or not
  12765. */
  12766. XmlLoader.prototype.isLoaded = function () {
  12767. return this._isLoaded;
  12768. };
  12769. /**
  12770. * Gets a loaded node / control by id.
  12771. * @param id the Controls id set in the xml
  12772. * @returns element of type Control
  12773. */
  12774. XmlLoader.prototype.getNodeById = function (id) {
  12775. return this._nodes[id];
  12776. };
  12777. /**
  12778. * Gets all loaded nodes / controls
  12779. * @returns Array of controls
  12780. */
  12781. XmlLoader.prototype.getNodes = function () {
  12782. return this._nodes;
  12783. };
  12784. /**
  12785. * Initiates the xml layout loading
  12786. * @param xmlFile defines the xml layout to load
  12787. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  12788. * @param callback defines the callback called on layout load.
  12789. */
  12790. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  12791. var xhttp = new XMLHttpRequest();
  12792. xhttp.onreadystatechange = function () {
  12793. if (xhttp.readyState == 4 && xhttp.status == 200) {
  12794. if (!xhttp.responseXML) {
  12795. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  12796. }
  12797. var xmlDoc = xhttp.responseXML.documentElement;
  12798. this._parseXml(xmlDoc.firstChild, rootNode);
  12799. this._isLoaded = true;
  12800. if (callback) {
  12801. callback();
  12802. }
  12803. }
  12804. }.bind(this);
  12805. xhttp.open("GET", xmlFile, true);
  12806. xhttp.send();
  12807. };
  12808. return XmlLoader;
  12809. }());
  12810. /***/ }),
  12811. /***/ "./3D/controls/abstractButton3D.ts":
  12812. /*!*****************************************!*\
  12813. !*** ./3D/controls/abstractButton3D.ts ***!
  12814. \*****************************************/
  12815. /*! exports provided: AbstractButton3D */
  12816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12817. "use strict";
  12818. __webpack_require__.r(__webpack_exports__);
  12819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12821. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12822. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12823. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12824. /**
  12825. * Class used as a root to all buttons
  12826. */
  12827. var AbstractButton3D = /** @class */ (function (_super) {
  12828. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12829. /**
  12830. * Creates a new button
  12831. * @param name defines the control name
  12832. */
  12833. function AbstractButton3D(name) {
  12834. return _super.call(this, name) || this;
  12835. }
  12836. AbstractButton3D.prototype._getTypeName = function () {
  12837. return "AbstractButton3D";
  12838. };
  12839. // Mesh association
  12840. AbstractButton3D.prototype._createNode = function (scene) {
  12841. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12842. };
  12843. return AbstractButton3D;
  12844. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12845. /***/ }),
  12846. /***/ "./3D/controls/button3D.ts":
  12847. /*!*********************************!*\
  12848. !*** ./3D/controls/button3D.ts ***!
  12849. \*********************************/
  12850. /*! exports provided: Button3D */
  12851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12852. "use strict";
  12853. __webpack_require__.r(__webpack_exports__);
  12854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12855. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12856. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12857. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12858. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12859. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12860. /**
  12861. * Class used to create a button in 3D
  12862. */
  12863. var Button3D = /** @class */ (function (_super) {
  12864. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12865. /**
  12866. * Creates a new button
  12867. * @param name defines the control name
  12868. */
  12869. function Button3D(name) {
  12870. var _this = _super.call(this, name) || this;
  12871. _this._contentResolution = 512;
  12872. _this._contentScaleRatio = 2;
  12873. // Default animations
  12874. _this.pointerEnterAnimation = function () {
  12875. if (!_this.mesh) {
  12876. return;
  12877. }
  12878. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12879. };
  12880. _this.pointerOutAnimation = function () {
  12881. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12882. };
  12883. _this.pointerDownAnimation = function () {
  12884. if (!_this.mesh) {
  12885. return;
  12886. }
  12887. _this.mesh.scaling.scaleInPlace(0.95);
  12888. };
  12889. _this.pointerUpAnimation = function () {
  12890. if (!_this.mesh) {
  12891. return;
  12892. }
  12893. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12894. };
  12895. return _this;
  12896. }
  12897. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12898. /**
  12899. * Gets or sets the texture resolution used to render content (512 by default)
  12900. */
  12901. get: function () {
  12902. return this._contentResolution;
  12903. },
  12904. set: function (value) {
  12905. if (this._contentResolution === value) {
  12906. return;
  12907. }
  12908. this._contentResolution = value;
  12909. this._resetContent();
  12910. },
  12911. enumerable: true,
  12912. configurable: true
  12913. });
  12914. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12915. /**
  12916. * Gets or sets the texture scale ratio used to render content (2 by default)
  12917. */
  12918. get: function () {
  12919. return this._contentScaleRatio;
  12920. },
  12921. set: function (value) {
  12922. if (this._contentScaleRatio === value) {
  12923. return;
  12924. }
  12925. this._contentScaleRatio = value;
  12926. this._resetContent();
  12927. },
  12928. enumerable: true,
  12929. configurable: true
  12930. });
  12931. Button3D.prototype._disposeFacadeTexture = function () {
  12932. if (this._facadeTexture) {
  12933. this._facadeTexture.dispose();
  12934. this._facadeTexture = null;
  12935. }
  12936. };
  12937. Button3D.prototype._resetContent = function () {
  12938. this._disposeFacadeTexture();
  12939. this.content = this._content;
  12940. };
  12941. Object.defineProperty(Button3D.prototype, "content", {
  12942. /**
  12943. * Gets or sets the GUI 2D content used to display the button's facade
  12944. */
  12945. get: function () {
  12946. return this._content;
  12947. },
  12948. set: function (value) {
  12949. this._content = value;
  12950. if (!this._host || !this._host.utilityLayer) {
  12951. return;
  12952. }
  12953. if (!this._facadeTexture) {
  12954. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  12955. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12956. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12957. this._facadeTexture.premulAlpha = true;
  12958. }
  12959. else {
  12960. this._facadeTexture.rootContainer.clearControls();
  12961. }
  12962. this._facadeTexture.addControl(value);
  12963. this._applyFacade(this._facadeTexture);
  12964. },
  12965. enumerable: true,
  12966. configurable: true
  12967. });
  12968. /**
  12969. * Apply the facade texture (created from the content property).
  12970. * This function can be overloaded by child classes
  12971. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12972. */
  12973. Button3D.prototype._applyFacade = function (facadeTexture) {
  12974. this._currentMaterial.emissiveTexture = facadeTexture;
  12975. };
  12976. Button3D.prototype._getTypeName = function () {
  12977. return "Button3D";
  12978. };
  12979. // Mesh association
  12980. Button3D.prototype._createNode = function (scene) {
  12981. var faceUV = new Array(6);
  12982. for (var i = 0; i < 6; i++) {
  12983. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12984. }
  12985. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12986. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12987. width: 1.0,
  12988. height: 1.0,
  12989. depth: 0.08,
  12990. faceUV: faceUV
  12991. }, scene);
  12992. return mesh;
  12993. };
  12994. Button3D.prototype._affectMaterial = function (mesh) {
  12995. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12996. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12997. mesh.material = material;
  12998. this._currentMaterial = material;
  12999. this._resetContent();
  13000. };
  13001. /**
  13002. * Releases all associated resources
  13003. */
  13004. Button3D.prototype.dispose = function () {
  13005. _super.prototype.dispose.call(this);
  13006. this._disposeFacadeTexture();
  13007. if (this._currentMaterial) {
  13008. this._currentMaterial.dispose();
  13009. }
  13010. };
  13011. return Button3D;
  13012. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13013. /***/ }),
  13014. /***/ "./3D/controls/container3D.ts":
  13015. /*!************************************!*\
  13016. !*** ./3D/controls/container3D.ts ***!
  13017. \************************************/
  13018. /*! exports provided: Container3D */
  13019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13020. "use strict";
  13021. __webpack_require__.r(__webpack_exports__);
  13022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13023. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13024. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13025. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13026. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13027. /**
  13028. * Class used to create containers for controls
  13029. */
  13030. var Container3D = /** @class */ (function (_super) {
  13031. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  13032. /**
  13033. * Creates a new container
  13034. * @param name defines the container name
  13035. */
  13036. function Container3D(name) {
  13037. var _this = _super.call(this, name) || this;
  13038. _this._blockLayout = false;
  13039. /**
  13040. * Gets the list of child controls
  13041. */
  13042. _this._children = new Array();
  13043. return _this;
  13044. }
  13045. Object.defineProperty(Container3D.prototype, "children", {
  13046. /**
  13047. * Gets the list of child controls
  13048. */
  13049. get: function () {
  13050. return this._children;
  13051. },
  13052. enumerable: true,
  13053. configurable: true
  13054. });
  13055. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13056. /**
  13057. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13058. * This is helpful to optimize layout operation when adding multiple children in a row
  13059. */
  13060. get: function () {
  13061. return this._blockLayout;
  13062. },
  13063. set: function (value) {
  13064. if (this._blockLayout === value) {
  13065. return;
  13066. }
  13067. this._blockLayout = value;
  13068. if (!this._blockLayout) {
  13069. this._arrangeChildren();
  13070. }
  13071. },
  13072. enumerable: true,
  13073. configurable: true
  13074. });
  13075. /**
  13076. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13077. * @returns the current container
  13078. */
  13079. Container3D.prototype.updateLayout = function () {
  13080. this._arrangeChildren();
  13081. return this;
  13082. };
  13083. /**
  13084. * Gets a boolean indicating if the given control is in the children of this control
  13085. * @param control defines the control to check
  13086. * @returns true if the control is in the child list
  13087. */
  13088. Container3D.prototype.containsControl = function (control) {
  13089. return this._children.indexOf(control) !== -1;
  13090. };
  13091. /**
  13092. * Adds a control to the children of this control
  13093. * @param control defines the control to add
  13094. * @returns the current container
  13095. */
  13096. Container3D.prototype.addControl = function (control) {
  13097. var index = this._children.indexOf(control);
  13098. if (index !== -1) {
  13099. return this;
  13100. }
  13101. control.parent = this;
  13102. control._host = this._host;
  13103. this._children.push(control);
  13104. if (this._host.utilityLayer) {
  13105. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13106. if (control.node) {
  13107. control.node.parent = this.node;
  13108. }
  13109. if (!this.blockLayout) {
  13110. this._arrangeChildren();
  13111. }
  13112. }
  13113. return this;
  13114. };
  13115. /**
  13116. * This function will be called everytime a new control is added
  13117. */
  13118. Container3D.prototype._arrangeChildren = function () {
  13119. };
  13120. Container3D.prototype._createNode = function (scene) {
  13121. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13122. };
  13123. /**
  13124. * Removes a control from the children of this control
  13125. * @param control defines the control to remove
  13126. * @returns the current container
  13127. */
  13128. Container3D.prototype.removeControl = function (control) {
  13129. var index = this._children.indexOf(control);
  13130. if (index !== -1) {
  13131. this._children.splice(index, 1);
  13132. control.parent = null;
  13133. control._disposeNode();
  13134. }
  13135. return this;
  13136. };
  13137. Container3D.prototype._getTypeName = function () {
  13138. return "Container3D";
  13139. };
  13140. /**
  13141. * Releases all associated resources
  13142. */
  13143. Container3D.prototype.dispose = function () {
  13144. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13145. var control = _a[_i];
  13146. control.dispose();
  13147. }
  13148. this._children = [];
  13149. _super.prototype.dispose.call(this);
  13150. };
  13151. /** Control rotation will remain unchanged */
  13152. Container3D.UNSET_ORIENTATION = 0;
  13153. /** Control will rotate to make it look at sphere central axis */
  13154. Container3D.FACEORIGIN_ORIENTATION = 1;
  13155. /** Control will rotate to make it look back at sphere central axis */
  13156. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13157. /** Control will rotate to look at z axis (0, 0, 1) */
  13158. Container3D.FACEFORWARD_ORIENTATION = 3;
  13159. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13160. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13161. return Container3D;
  13162. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13163. /***/ }),
  13164. /***/ "./3D/controls/control3D.ts":
  13165. /*!**********************************!*\
  13166. !*** ./3D/controls/control3D.ts ***!
  13167. \**********************************/
  13168. /*! exports provided: Control3D */
  13169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13170. "use strict";
  13171. __webpack_require__.r(__webpack_exports__);
  13172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13173. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  13174. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13175. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13176. /**
  13177. * Class used as base class for controls
  13178. */
  13179. var Control3D = /** @class */ (function () {
  13180. /**
  13181. * Creates a new control
  13182. * @param name defines the control name
  13183. */
  13184. function Control3D(
  13185. /** Defines the control name */
  13186. name) {
  13187. this.name = name;
  13188. this._downCount = 0;
  13189. this._enterCount = -1;
  13190. this._downPointerIds = {};
  13191. this._isVisible = true;
  13192. /**
  13193. * An event triggered when the pointer move over the control
  13194. */
  13195. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13196. /**
  13197. * An event triggered when the pointer move out of the control
  13198. */
  13199. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13200. /**
  13201. * An event triggered when the pointer taps the control
  13202. */
  13203. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13204. /**
  13205. * An event triggered when pointer is up
  13206. */
  13207. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13208. /**
  13209. * An event triggered when a control is clicked on (with a mouse)
  13210. */
  13211. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13212. /**
  13213. * An event triggered when pointer enters the control
  13214. */
  13215. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13216. // Behaviors
  13217. this._behaviors = new Array();
  13218. }
  13219. Object.defineProperty(Control3D.prototype, "position", {
  13220. /** Gets or sets the control position in world space */
  13221. get: function () {
  13222. if (!this._node) {
  13223. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13224. }
  13225. return this._node.position;
  13226. },
  13227. set: function (value) {
  13228. if (!this._node) {
  13229. return;
  13230. }
  13231. this._node.position = value;
  13232. },
  13233. enumerable: true,
  13234. configurable: true
  13235. });
  13236. Object.defineProperty(Control3D.prototype, "scaling", {
  13237. /** Gets or sets the control scaling in world space */
  13238. get: function () {
  13239. if (!this._node) {
  13240. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13241. }
  13242. return this._node.scaling;
  13243. },
  13244. set: function (value) {
  13245. if (!this._node) {
  13246. return;
  13247. }
  13248. this._node.scaling = value;
  13249. },
  13250. enumerable: true,
  13251. configurable: true
  13252. });
  13253. Object.defineProperty(Control3D.prototype, "behaviors", {
  13254. /**
  13255. * Gets the list of attached behaviors
  13256. * @see http://doc.babylonjs.com/features/behaviour
  13257. */
  13258. get: function () {
  13259. return this._behaviors;
  13260. },
  13261. enumerable: true,
  13262. configurable: true
  13263. });
  13264. /**
  13265. * Attach a behavior to the control
  13266. * @see http://doc.babylonjs.com/features/behaviour
  13267. * @param behavior defines the behavior to attach
  13268. * @returns the current control
  13269. */
  13270. Control3D.prototype.addBehavior = function (behavior) {
  13271. var _this = this;
  13272. var index = this._behaviors.indexOf(behavior);
  13273. if (index !== -1) {
  13274. return this;
  13275. }
  13276. behavior.init();
  13277. var scene = this._host.scene;
  13278. if (scene.isLoading) {
  13279. // We defer the attach when the scene will be loaded
  13280. scene.onDataLoadedObservable.addOnce(function () {
  13281. behavior.attach(_this);
  13282. });
  13283. }
  13284. else {
  13285. behavior.attach(this);
  13286. }
  13287. this._behaviors.push(behavior);
  13288. return this;
  13289. };
  13290. /**
  13291. * Remove an attached behavior
  13292. * @see http://doc.babylonjs.com/features/behaviour
  13293. * @param behavior defines the behavior to attach
  13294. * @returns the current control
  13295. */
  13296. Control3D.prototype.removeBehavior = function (behavior) {
  13297. var index = this._behaviors.indexOf(behavior);
  13298. if (index === -1) {
  13299. return this;
  13300. }
  13301. this._behaviors[index].detach();
  13302. this._behaviors.splice(index, 1);
  13303. return this;
  13304. };
  13305. /**
  13306. * Gets an attached behavior by name
  13307. * @param name defines the name of the behavior to look for
  13308. * @see http://doc.babylonjs.com/features/behaviour
  13309. * @returns null if behavior was not found else the requested behavior
  13310. */
  13311. Control3D.prototype.getBehaviorByName = function (name) {
  13312. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13313. var behavior = _a[_i];
  13314. if (behavior.name === name) {
  13315. return behavior;
  13316. }
  13317. }
  13318. return null;
  13319. };
  13320. Object.defineProperty(Control3D.prototype, "isVisible", {
  13321. /** Gets or sets a boolean indicating if the control is visible */
  13322. get: function () {
  13323. return this._isVisible;
  13324. },
  13325. set: function (value) {
  13326. if (this._isVisible === value) {
  13327. return;
  13328. }
  13329. this._isVisible = value;
  13330. var mesh = this.mesh;
  13331. if (mesh) {
  13332. mesh.setEnabled(value);
  13333. }
  13334. },
  13335. enumerable: true,
  13336. configurable: true
  13337. });
  13338. Object.defineProperty(Control3D.prototype, "typeName", {
  13339. /**
  13340. * Gets a string representing the class name
  13341. */
  13342. get: function () {
  13343. return this._getTypeName();
  13344. },
  13345. enumerable: true,
  13346. configurable: true
  13347. });
  13348. /**
  13349. * Get the current class name of the control.
  13350. * @returns current class name
  13351. */
  13352. Control3D.prototype.getClassName = function () {
  13353. return this._getTypeName();
  13354. };
  13355. Control3D.prototype._getTypeName = function () {
  13356. return "Control3D";
  13357. };
  13358. Object.defineProperty(Control3D.prototype, "node", {
  13359. /**
  13360. * Gets the transform node used by this control
  13361. */
  13362. get: function () {
  13363. return this._node;
  13364. },
  13365. enumerable: true,
  13366. configurable: true
  13367. });
  13368. Object.defineProperty(Control3D.prototype, "mesh", {
  13369. /**
  13370. * Gets the mesh used to render this control
  13371. */
  13372. get: function () {
  13373. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13374. return this._node;
  13375. }
  13376. return null;
  13377. },
  13378. enumerable: true,
  13379. configurable: true
  13380. });
  13381. /**
  13382. * Link the control as child of the given node
  13383. * @param node defines the node to link to. Use null to unlink the control
  13384. * @returns the current control
  13385. */
  13386. Control3D.prototype.linkToTransformNode = function (node) {
  13387. if (this._node) {
  13388. this._node.parent = node;
  13389. }
  13390. return this;
  13391. };
  13392. /** @hidden **/
  13393. Control3D.prototype._prepareNode = function (scene) {
  13394. if (!this._node) {
  13395. this._node = this._createNode(scene);
  13396. if (!this.node) {
  13397. return;
  13398. }
  13399. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13400. this._node.position = this.position;
  13401. this._node.scaling = this.scaling;
  13402. var mesh = this.mesh;
  13403. if (mesh) {
  13404. mesh.isPickable = true;
  13405. this._affectMaterial(mesh);
  13406. }
  13407. }
  13408. };
  13409. /**
  13410. * Node creation.
  13411. * Can be overriden by children
  13412. * @param scene defines the scene where the node must be attached
  13413. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13414. */
  13415. Control3D.prototype._createNode = function (scene) {
  13416. // Do nothing by default
  13417. return null;
  13418. };
  13419. /**
  13420. * Affect a material to the given mesh
  13421. * @param mesh defines the mesh which will represent the control
  13422. */
  13423. Control3D.prototype._affectMaterial = function (mesh) {
  13424. mesh.material = null;
  13425. };
  13426. // Pointers
  13427. /** @hidden */
  13428. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13429. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13430. };
  13431. /** @hidden */
  13432. Control3D.prototype._onPointerEnter = function (target) {
  13433. if (this._enterCount > 0) {
  13434. return false;
  13435. }
  13436. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13437. this._enterCount = 0;
  13438. }
  13439. this._enterCount++;
  13440. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13441. if (this.pointerEnterAnimation) {
  13442. this.pointerEnterAnimation();
  13443. }
  13444. return true;
  13445. };
  13446. /** @hidden */
  13447. Control3D.prototype._onPointerOut = function (target) {
  13448. this._enterCount = 0;
  13449. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13450. if (this.pointerOutAnimation) {
  13451. this.pointerOutAnimation();
  13452. }
  13453. };
  13454. /** @hidden */
  13455. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13456. if (this._downCount !== 0) {
  13457. this._downCount++;
  13458. return false;
  13459. }
  13460. this._downCount++;
  13461. this._downPointerIds[pointerId] = true;
  13462. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13463. if (this.pointerDownAnimation) {
  13464. this.pointerDownAnimation();
  13465. }
  13466. return true;
  13467. };
  13468. /** @hidden */
  13469. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13470. this._downCount--;
  13471. delete this._downPointerIds[pointerId];
  13472. if (this._downCount < 0) {
  13473. // Handle if forcePointerUp was called prior to this
  13474. this._downCount = 0;
  13475. return;
  13476. }
  13477. if (this._downCount == 0) {
  13478. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13479. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13480. }
  13481. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13482. if (this.pointerUpAnimation) {
  13483. this.pointerUpAnimation();
  13484. }
  13485. }
  13486. };
  13487. /** @hidden */
  13488. Control3D.prototype.forcePointerUp = function (pointerId) {
  13489. if (pointerId === void 0) { pointerId = null; }
  13490. if (pointerId !== null) {
  13491. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13492. }
  13493. else {
  13494. for (var key in this._downPointerIds) {
  13495. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13496. }
  13497. if (this._downCount > 0) {
  13498. this._downCount = 1;
  13499. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13500. }
  13501. }
  13502. };
  13503. /** @hidden */
  13504. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13505. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13506. this._onPointerMove(this, pickedPoint);
  13507. var previousControlOver = this._host._lastControlOver[pointerId];
  13508. if (previousControlOver && previousControlOver !== this) {
  13509. previousControlOver._onPointerOut(this);
  13510. }
  13511. if (previousControlOver !== this) {
  13512. this._onPointerEnter(this);
  13513. }
  13514. this._host._lastControlOver[pointerId] = this;
  13515. return true;
  13516. }
  13517. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13518. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13519. this._host._lastControlDown[pointerId] = this;
  13520. this._host._lastPickedControl = this;
  13521. return true;
  13522. }
  13523. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13524. if (this._host._lastControlDown[pointerId]) {
  13525. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13526. }
  13527. delete this._host._lastControlDown[pointerId];
  13528. return true;
  13529. }
  13530. return false;
  13531. };
  13532. /** @hidden */
  13533. Control3D.prototype._disposeNode = function () {
  13534. if (this._node) {
  13535. this._node.dispose();
  13536. this._node = null;
  13537. }
  13538. };
  13539. /**
  13540. * Releases all associated resources
  13541. */
  13542. Control3D.prototype.dispose = function () {
  13543. this.onPointerDownObservable.clear();
  13544. this.onPointerEnterObservable.clear();
  13545. this.onPointerMoveObservable.clear();
  13546. this.onPointerOutObservable.clear();
  13547. this.onPointerUpObservable.clear();
  13548. this.onPointerClickObservable.clear();
  13549. this._disposeNode();
  13550. // Behaviors
  13551. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13552. var behavior = _a[_i];
  13553. behavior.detach();
  13554. }
  13555. };
  13556. return Control3D;
  13557. }());
  13558. /***/ }),
  13559. /***/ "./3D/controls/cylinderPanel.ts":
  13560. /*!**************************************!*\
  13561. !*** ./3D/controls/cylinderPanel.ts ***!
  13562. \**************************************/
  13563. /*! exports provided: CylinderPanel */
  13564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13565. "use strict";
  13566. __webpack_require__.r(__webpack_exports__);
  13567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13569. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13570. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13571. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13572. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13573. /**
  13574. * Class used to create a container panel deployed on the surface of a cylinder
  13575. */
  13576. var CylinderPanel = /** @class */ (function (_super) {
  13577. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13578. function CylinderPanel() {
  13579. var _this = _super !== null && _super.apply(this, arguments) || this;
  13580. _this._radius = 5.0;
  13581. return _this;
  13582. }
  13583. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13584. /**
  13585. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13586. */
  13587. get: function () {
  13588. return this._radius;
  13589. },
  13590. set: function (value) {
  13591. var _this = this;
  13592. if (this._radius === value) {
  13593. return;
  13594. }
  13595. this._radius = value;
  13596. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13597. _this._arrangeChildren();
  13598. });
  13599. },
  13600. enumerable: true,
  13601. configurable: true
  13602. });
  13603. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13604. var mesh = control.mesh;
  13605. if (!mesh) {
  13606. return;
  13607. }
  13608. var newPos = this._cylindricalMapping(nodePosition);
  13609. control.position = newPos;
  13610. switch (this.orientation) {
  13611. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13612. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13613. break;
  13614. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13615. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13616. break;
  13617. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13618. break;
  13619. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13620. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13621. break;
  13622. }
  13623. };
  13624. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13625. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13626. var yAngle = (source.x / this._radius);
  13627. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13628. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13629. };
  13630. return CylinderPanel;
  13631. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13632. /***/ }),
  13633. /***/ "./3D/controls/holographicButton.ts":
  13634. /*!******************************************!*\
  13635. !*** ./3D/controls/holographicButton.ts ***!
  13636. \******************************************/
  13637. /*! exports provided: HolographicButton */
  13638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13639. "use strict";
  13640. __webpack_require__.r(__webpack_exports__);
  13641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13642. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13643. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13644. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13645. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13646. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13647. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13648. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13649. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13650. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13651. /**
  13652. * Class used to create a holographic button in 3D
  13653. */
  13654. var HolographicButton = /** @class */ (function (_super) {
  13655. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13656. /**
  13657. * Creates a new button
  13658. * @param name defines the control name
  13659. */
  13660. function HolographicButton(name, shareMaterials) {
  13661. if (shareMaterials === void 0) { shareMaterials = true; }
  13662. var _this = _super.call(this, name) || this;
  13663. _this._shareMaterials = true;
  13664. _this._shareMaterials = shareMaterials;
  13665. // Default animations
  13666. _this.pointerEnterAnimation = function () {
  13667. if (!_this.mesh) {
  13668. return;
  13669. }
  13670. _this._frontPlate.setEnabled(true);
  13671. };
  13672. _this.pointerOutAnimation = function () {
  13673. if (!_this.mesh) {
  13674. return;
  13675. }
  13676. _this._frontPlate.setEnabled(false);
  13677. };
  13678. return _this;
  13679. }
  13680. HolographicButton.prototype._disposeTooltip = function () {
  13681. this._tooltipFade = null;
  13682. if (this._tooltipTextBlock) {
  13683. this._tooltipTextBlock.dispose();
  13684. }
  13685. if (this._tooltipTexture) {
  13686. this._tooltipTexture.dispose();
  13687. }
  13688. if (this._tooltipMesh) {
  13689. this._tooltipMesh.dispose();
  13690. }
  13691. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13692. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13693. };
  13694. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13695. get: function () {
  13696. if (this._tooltipTextBlock) {
  13697. return this._tooltipTextBlock.text;
  13698. }
  13699. return null;
  13700. },
  13701. /**
  13702. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13703. */
  13704. set: function (text) {
  13705. var _this = this;
  13706. if (!text) {
  13707. this._disposeTooltip();
  13708. return;
  13709. }
  13710. if (!this._tooltipFade) {
  13711. // Create tooltip with mesh and text
  13712. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13713. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  13714. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13715. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13716. tooltipBackground.material = mat;
  13717. tooltipBackground.isPickable = false;
  13718. this._tooltipMesh.addChild(tooltipBackground);
  13719. tooltipBackground.position.z = 0.05;
  13720. this._tooltipMesh.scaling.y = 1 / 3;
  13721. this._tooltipMesh.position.y = 0.7;
  13722. this._tooltipMesh.position.z = -0.15;
  13723. this._tooltipMesh.isPickable = false;
  13724. this._tooltipMesh.parent = this._backPlate;
  13725. // Create text texture for the tooltip
  13726. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13727. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13728. this._tooltipTextBlock.scaleY = 3;
  13729. this._tooltipTextBlock.color = "white";
  13730. this._tooltipTextBlock.fontSize = 130;
  13731. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13732. // Add hover action to tooltip
  13733. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13734. this._tooltipFade.delay = 500;
  13735. this._tooltipMesh.addBehavior(this._tooltipFade);
  13736. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13737. if (_this._tooltipFade) {
  13738. _this._tooltipFade.fadeIn(true);
  13739. }
  13740. });
  13741. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13742. if (_this._tooltipFade) {
  13743. _this._tooltipFade.fadeIn(false);
  13744. }
  13745. });
  13746. }
  13747. if (this._tooltipTextBlock) {
  13748. this._tooltipTextBlock.text = text;
  13749. }
  13750. },
  13751. enumerable: true,
  13752. configurable: true
  13753. });
  13754. Object.defineProperty(HolographicButton.prototype, "text", {
  13755. /**
  13756. * Gets or sets text for the button
  13757. */
  13758. get: function () {
  13759. return this._text;
  13760. },
  13761. set: function (value) {
  13762. if (this._text === value) {
  13763. return;
  13764. }
  13765. this._text = value;
  13766. this._rebuildContent();
  13767. },
  13768. enumerable: true,
  13769. configurable: true
  13770. });
  13771. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13772. /**
  13773. * Gets or sets the image url for the button
  13774. */
  13775. get: function () {
  13776. return this._imageUrl;
  13777. },
  13778. set: function (value) {
  13779. if (this._imageUrl === value) {
  13780. return;
  13781. }
  13782. this._imageUrl = value;
  13783. this._rebuildContent();
  13784. },
  13785. enumerable: true,
  13786. configurable: true
  13787. });
  13788. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13789. /**
  13790. * Gets the back material used by this button
  13791. */
  13792. get: function () {
  13793. return this._backMaterial;
  13794. },
  13795. enumerable: true,
  13796. configurable: true
  13797. });
  13798. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13799. /**
  13800. * Gets the front material used by this button
  13801. */
  13802. get: function () {
  13803. return this._frontMaterial;
  13804. },
  13805. enumerable: true,
  13806. configurable: true
  13807. });
  13808. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13809. /**
  13810. * Gets the plate material used by this button
  13811. */
  13812. get: function () {
  13813. return this._plateMaterial;
  13814. },
  13815. enumerable: true,
  13816. configurable: true
  13817. });
  13818. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13819. /**
  13820. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13821. */
  13822. get: function () {
  13823. return this._shareMaterials;
  13824. },
  13825. enumerable: true,
  13826. configurable: true
  13827. });
  13828. HolographicButton.prototype._getTypeName = function () {
  13829. return "HolographicButton";
  13830. };
  13831. HolographicButton.prototype._rebuildContent = function () {
  13832. this._disposeFacadeTexture();
  13833. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13834. panel.isVertical = true;
  13835. if (this._imageUrl) {
  13836. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13837. image.source = this._imageUrl;
  13838. image.paddingTop = "40px";
  13839. image.height = "180px";
  13840. image.width = "100px";
  13841. image.paddingBottom = "40px";
  13842. panel.addControl(image);
  13843. }
  13844. if (this._text) {
  13845. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13846. text.text = this._text;
  13847. text.color = "white";
  13848. text.height = "30px";
  13849. text.fontSize = 24;
  13850. panel.addControl(text);
  13851. }
  13852. if (this._frontPlate) {
  13853. this.content = panel;
  13854. }
  13855. };
  13856. // Mesh association
  13857. HolographicButton.prototype._createNode = function (scene) {
  13858. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13859. width: 1.0,
  13860. height: 1.0,
  13861. depth: 0.08
  13862. }, scene);
  13863. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13864. width: 1.0,
  13865. height: 1.0,
  13866. depth: 0.08
  13867. }, scene);
  13868. this._frontPlate.parent = this._backPlate;
  13869. this._frontPlate.position.z = -0.08;
  13870. this._frontPlate.isPickable = false;
  13871. this._frontPlate.setEnabled(false);
  13872. this._textPlate = _super.prototype._createNode.call(this, scene);
  13873. this._textPlate.parent = this._backPlate;
  13874. this._textPlate.position.z = -0.08;
  13875. this._textPlate.isPickable = false;
  13876. return this._backPlate;
  13877. };
  13878. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13879. this._plateMaterial.emissiveTexture = facadeTexture;
  13880. this._plateMaterial.opacityTexture = facadeTexture;
  13881. };
  13882. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13883. var _this = this;
  13884. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13885. this._backMaterial.renderHoverLight = true;
  13886. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13887. if (pickedPoint) {
  13888. _this._backMaterial.hoverPosition = pickedPoint;
  13889. _this._backMaterial.hoverColor.a = 1.0;
  13890. }
  13891. else {
  13892. _this._backMaterial.hoverColor.a = 0;
  13893. }
  13894. });
  13895. };
  13896. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13897. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13898. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13899. this._frontMaterial.alpha = 0.5; // Additive
  13900. this._frontMaterial.renderBorders = true;
  13901. };
  13902. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13903. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13904. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13905. };
  13906. HolographicButton.prototype._affectMaterial = function (mesh) {
  13907. // Back
  13908. if (this._shareMaterials) {
  13909. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13910. this._createBackMaterial(mesh);
  13911. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13912. }
  13913. else {
  13914. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13915. }
  13916. // Front
  13917. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13918. this._createFrontMaterial(mesh);
  13919. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13920. }
  13921. else {
  13922. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13923. }
  13924. }
  13925. else {
  13926. this._createBackMaterial(mesh);
  13927. this._createFrontMaterial(mesh);
  13928. }
  13929. this._createPlateMaterial(mesh);
  13930. this._backPlate.material = this._backMaterial;
  13931. this._frontPlate.material = this._frontMaterial;
  13932. this._textPlate.material = this._plateMaterial;
  13933. this._rebuildContent();
  13934. };
  13935. /**
  13936. * Releases all associated resources
  13937. */
  13938. HolographicButton.prototype.dispose = function () {
  13939. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13940. this._disposeTooltip();
  13941. if (!this.shareMaterials) {
  13942. this._backMaterial.dispose();
  13943. this._frontMaterial.dispose();
  13944. this._plateMaterial.dispose();
  13945. if (this._pickedPointObserver) {
  13946. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13947. this._pickedPointObserver = null;
  13948. }
  13949. }
  13950. };
  13951. return HolographicButton;
  13952. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13953. /***/ }),
  13954. /***/ "./3D/controls/index.ts":
  13955. /*!******************************!*\
  13956. !*** ./3D/controls/index.ts ***!
  13957. \******************************/
  13958. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13960. "use strict";
  13961. __webpack_require__.r(__webpack_exports__);
  13962. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13964. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13966. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13968. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13970. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13972. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13974. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13976. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13978. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13980. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13982. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13984. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13986. /***/ }),
  13987. /***/ "./3D/controls/meshButton3D.ts":
  13988. /*!*************************************!*\
  13989. !*** ./3D/controls/meshButton3D.ts ***!
  13990. \*************************************/
  13991. /*! exports provided: MeshButton3D */
  13992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13993. "use strict";
  13994. __webpack_require__.r(__webpack_exports__);
  13995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13996. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13997. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13998. /**
  13999. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14000. */
  14001. var MeshButton3D = /** @class */ (function (_super) {
  14002. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  14003. /**
  14004. * Creates a new 3D button based on a mesh
  14005. * @param mesh mesh to become a 3D button
  14006. * @param name defines the control name
  14007. */
  14008. function MeshButton3D(mesh, name) {
  14009. var _this = _super.call(this, name) || this;
  14010. _this._currentMesh = mesh;
  14011. /**
  14012. * Provides a default behavior on hover/out & up/down
  14013. * Override those function to create your own desired behavior specific to your mesh
  14014. */
  14015. _this.pointerEnterAnimation = function () {
  14016. if (!_this.mesh) {
  14017. return;
  14018. }
  14019. _this.mesh.scaling.scaleInPlace(1.1);
  14020. };
  14021. _this.pointerOutAnimation = function () {
  14022. if (!_this.mesh) {
  14023. return;
  14024. }
  14025. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14026. };
  14027. _this.pointerDownAnimation = function () {
  14028. if (!_this.mesh) {
  14029. return;
  14030. }
  14031. _this.mesh.scaling.scaleInPlace(0.95);
  14032. };
  14033. _this.pointerUpAnimation = function () {
  14034. if (!_this.mesh) {
  14035. return;
  14036. }
  14037. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14038. };
  14039. return _this;
  14040. }
  14041. MeshButton3D.prototype._getTypeName = function () {
  14042. return "MeshButton3D";
  14043. };
  14044. // Mesh association
  14045. MeshButton3D.prototype._createNode = function (scene) {
  14046. var _this = this;
  14047. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14048. mesh.metadata = _this;
  14049. });
  14050. return this._currentMesh;
  14051. };
  14052. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14053. };
  14054. return MeshButton3D;
  14055. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14056. /***/ }),
  14057. /***/ "./3D/controls/planePanel.ts":
  14058. /*!***********************************!*\
  14059. !*** ./3D/controls/planePanel.ts ***!
  14060. \***********************************/
  14061. /*! exports provided: PlanePanel */
  14062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14063. "use strict";
  14064. __webpack_require__.r(__webpack_exports__);
  14065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14066. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14067. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14068. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14069. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14070. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14071. /**
  14072. * Class used to create a container panel deployed on the surface of a plane
  14073. */
  14074. var PlanePanel = /** @class */ (function (_super) {
  14075. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  14076. function PlanePanel() {
  14077. return _super !== null && _super.apply(this, arguments) || this;
  14078. }
  14079. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14080. var mesh = control.mesh;
  14081. if (!mesh) {
  14082. return;
  14083. }
  14084. control.position = nodePosition.clone();
  14085. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14086. target.copyFrom(nodePosition);
  14087. switch (this.orientation) {
  14088. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14089. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14090. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14091. mesh.lookAt(target);
  14092. break;
  14093. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14094. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14095. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14096. mesh.lookAt(target);
  14097. break;
  14098. }
  14099. };
  14100. return PlanePanel;
  14101. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14102. /***/ }),
  14103. /***/ "./3D/controls/scatterPanel.ts":
  14104. /*!*************************************!*\
  14105. !*** ./3D/controls/scatterPanel.ts ***!
  14106. \*************************************/
  14107. /*! exports provided: ScatterPanel */
  14108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14109. "use strict";
  14110. __webpack_require__.r(__webpack_exports__);
  14111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14112. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14113. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14114. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14115. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14116. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14117. /**
  14118. * Class used to create a container panel where items get randomized planar mapping
  14119. */
  14120. var ScatterPanel = /** @class */ (function (_super) {
  14121. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  14122. function ScatterPanel() {
  14123. var _this = _super !== null && _super.apply(this, arguments) || this;
  14124. _this._iteration = 100.0;
  14125. return _this;
  14126. }
  14127. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14128. /**
  14129. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14130. */
  14131. get: function () {
  14132. return this._iteration;
  14133. },
  14134. set: function (value) {
  14135. var _this = this;
  14136. if (this._iteration === value) {
  14137. return;
  14138. }
  14139. this._iteration = value;
  14140. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14141. _this._arrangeChildren();
  14142. });
  14143. },
  14144. enumerable: true,
  14145. configurable: true
  14146. });
  14147. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14148. var mesh = control.mesh;
  14149. var newPos = this._scatterMapping(nodePosition);
  14150. if (!mesh) {
  14151. return;
  14152. }
  14153. switch (this.orientation) {
  14154. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14155. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14156. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14157. break;
  14158. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14159. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14160. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14161. break;
  14162. }
  14163. control.position = newPos;
  14164. };
  14165. ScatterPanel.prototype._scatterMapping = function (source) {
  14166. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14167. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14168. return source;
  14169. };
  14170. ScatterPanel.prototype._finalProcessing = function () {
  14171. var meshes = [];
  14172. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14173. var child = _a[_i];
  14174. if (!child.mesh) {
  14175. continue;
  14176. }
  14177. meshes.push(child.mesh);
  14178. }
  14179. for (var count = 0; count < this._iteration; count++) {
  14180. meshes.sort(function (a, b) {
  14181. var distance1 = a.position.lengthSquared();
  14182. var distance2 = b.position.lengthSquared();
  14183. if (distance1 < distance2) {
  14184. return 1;
  14185. }
  14186. else if (distance1 > distance2) {
  14187. return -1;
  14188. }
  14189. return 0;
  14190. });
  14191. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14192. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14193. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14194. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14195. for (var i = 0; i < meshes.length - 1; i++) {
  14196. for (var j = i + 1; j < meshes.length; j++) {
  14197. if (i != j) {
  14198. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14199. // Ignore Z axis
  14200. difference2D.x = difference.x;
  14201. difference2D.y = difference.y;
  14202. var combinedRadius = cellSize;
  14203. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14204. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14205. distance -= minSeparation;
  14206. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14207. difference2D.normalize();
  14208. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14209. meshes[j].position.addInPlace(difference);
  14210. meshes[i].position.subtractInPlace(difference);
  14211. }
  14212. }
  14213. }
  14214. }
  14215. }
  14216. };
  14217. return ScatterPanel;
  14218. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14219. /***/ }),
  14220. /***/ "./3D/controls/spherePanel.ts":
  14221. /*!************************************!*\
  14222. !*** ./3D/controls/spherePanel.ts ***!
  14223. \************************************/
  14224. /*! exports provided: SpherePanel */
  14225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14226. "use strict";
  14227. __webpack_require__.r(__webpack_exports__);
  14228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14229. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14230. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14231. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14232. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14233. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14234. /**
  14235. * Class used to create a container panel deployed on the surface of a sphere
  14236. */
  14237. var SpherePanel = /** @class */ (function (_super) {
  14238. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  14239. function SpherePanel() {
  14240. var _this = _super !== null && _super.apply(this, arguments) || this;
  14241. _this._radius = 5.0;
  14242. return _this;
  14243. }
  14244. Object.defineProperty(SpherePanel.prototype, "radius", {
  14245. /**
  14246. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14247. */
  14248. get: function () {
  14249. return this._radius;
  14250. },
  14251. set: function (value) {
  14252. var _this = this;
  14253. if (this._radius === value) {
  14254. return;
  14255. }
  14256. this._radius = value;
  14257. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14258. _this._arrangeChildren();
  14259. });
  14260. },
  14261. enumerable: true,
  14262. configurable: true
  14263. });
  14264. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  14265. var mesh = control.mesh;
  14266. if (!mesh) {
  14267. return;
  14268. }
  14269. var newPos = this._sphericalMapping(nodePosition);
  14270. control.position = newPos;
  14271. switch (this.orientation) {
  14272. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14273. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  14274. break;
  14275. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14276. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  14277. break;
  14278. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14279. break;
  14280. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14281. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14282. break;
  14283. }
  14284. };
  14285. SpherePanel.prototype._sphericalMapping = function (source) {
  14286. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  14287. var xAngle = (source.y / this._radius);
  14288. var yAngle = -(source.x / this._radius);
  14289. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14290. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14291. };
  14292. return SpherePanel;
  14293. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14294. /***/ }),
  14295. /***/ "./3D/controls/stackPanel3D.ts":
  14296. /*!*************************************!*\
  14297. !*** ./3D/controls/stackPanel3D.ts ***!
  14298. \*************************************/
  14299. /*! exports provided: StackPanel3D */
  14300. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14301. "use strict";
  14302. __webpack_require__.r(__webpack_exports__);
  14303. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  14304. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14305. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14306. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14307. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14308. /**
  14309. * Class used to create a stack panel in 3D on XY plane
  14310. */
  14311. var StackPanel3D = /** @class */ (function (_super) {
  14312. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  14313. /**
  14314. * Creates new StackPanel
  14315. * @param isVertical
  14316. */
  14317. function StackPanel3D(isVertical) {
  14318. if (isVertical === void 0) { isVertical = false; }
  14319. var _this = _super.call(this) || this;
  14320. _this._isVertical = false;
  14321. /**
  14322. * Gets or sets the distance between elements
  14323. */
  14324. _this.margin = 0.1;
  14325. _this._isVertical = isVertical;
  14326. return _this;
  14327. }
  14328. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  14329. /**
  14330. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  14331. */
  14332. get: function () {
  14333. return this._isVertical;
  14334. },
  14335. set: function (value) {
  14336. var _this = this;
  14337. if (this._isVertical === value) {
  14338. return;
  14339. }
  14340. this._isVertical = value;
  14341. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14342. _this._arrangeChildren();
  14343. });
  14344. },
  14345. enumerable: true,
  14346. configurable: true
  14347. });
  14348. StackPanel3D.prototype._arrangeChildren = function () {
  14349. var width = 0;
  14350. var height = 0;
  14351. var controlCount = 0;
  14352. var extendSizes = [];
  14353. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14354. // Measure
  14355. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14356. var child = _a[_i];
  14357. if (!child.mesh) {
  14358. continue;
  14359. }
  14360. controlCount++;
  14361. child.mesh.computeWorldMatrix(true);
  14362. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14363. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14364. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14365. extendSizes.push(extendSize);
  14366. if (this._isVertical) {
  14367. height += extendSize.y;
  14368. }
  14369. else {
  14370. width += extendSize.x;
  14371. }
  14372. }
  14373. if (this._isVertical) {
  14374. height += (controlCount - 1) * this.margin / 2;
  14375. }
  14376. else {
  14377. width += (controlCount - 1) * this.margin / 2;
  14378. }
  14379. // Arrange
  14380. var offset;
  14381. if (this._isVertical) {
  14382. offset = -height;
  14383. }
  14384. else {
  14385. offset = -width;
  14386. }
  14387. var index = 0;
  14388. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14389. var child = _c[_b];
  14390. if (!child.mesh) {
  14391. continue;
  14392. }
  14393. controlCount--;
  14394. var extendSize = extendSizes[index++];
  14395. if (this._isVertical) {
  14396. child.position.y = offset + extendSize.y;
  14397. child.position.x = 0;
  14398. offset += extendSize.y * 2;
  14399. }
  14400. else {
  14401. child.position.x = offset + extendSize.x;
  14402. child.position.y = 0;
  14403. offset += extendSize.x * 2;
  14404. }
  14405. offset += (controlCount > 0 ? this.margin : 0);
  14406. }
  14407. };
  14408. return StackPanel3D;
  14409. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14410. /***/ }),
  14411. /***/ "./3D/controls/volumeBasedPanel.ts":
  14412. /*!*****************************************!*\
  14413. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14414. \*****************************************/
  14415. /*! exports provided: VolumeBasedPanel */
  14416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14417. "use strict";
  14418. __webpack_require__.r(__webpack_exports__);
  14419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14420. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14421. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14422. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14423. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14424. /**
  14425. * Abstract class used to create a container panel deployed on the surface of a volume
  14426. */
  14427. var VolumeBasedPanel = /** @class */ (function (_super) {
  14428. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  14429. /**
  14430. * Creates new VolumeBasedPanel
  14431. */
  14432. function VolumeBasedPanel() {
  14433. var _this = _super.call(this) || this;
  14434. _this._columns = 10;
  14435. _this._rows = 0;
  14436. _this._rowThenColum = true;
  14437. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14438. /**
  14439. * Gets or sets the distance between elements
  14440. */
  14441. _this.margin = 0;
  14442. return _this;
  14443. }
  14444. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14445. /**
  14446. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14447. * | Value | Type | Description |
  14448. * | ----- | ----------------------------------- | ----------- |
  14449. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14450. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14451. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14452. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14453. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14454. */
  14455. get: function () {
  14456. return this._orientation;
  14457. },
  14458. set: function (value) {
  14459. var _this = this;
  14460. if (this._orientation === value) {
  14461. return;
  14462. }
  14463. this._orientation = value;
  14464. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14465. _this._arrangeChildren();
  14466. });
  14467. },
  14468. enumerable: true,
  14469. configurable: true
  14470. });
  14471. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14472. /**
  14473. * Gets or sets the number of columns requested (10 by default).
  14474. * The panel will automatically compute the number of rows based on number of child controls.
  14475. */
  14476. get: function () {
  14477. return this._columns;
  14478. },
  14479. set: function (value) {
  14480. var _this = this;
  14481. if (this._columns === value) {
  14482. return;
  14483. }
  14484. this._columns = value;
  14485. this._rowThenColum = true;
  14486. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14487. _this._arrangeChildren();
  14488. });
  14489. },
  14490. enumerable: true,
  14491. configurable: true
  14492. });
  14493. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14494. /**
  14495. * Gets or sets a the number of rows requested.
  14496. * The panel will automatically compute the number of columns based on number of child controls.
  14497. */
  14498. get: function () {
  14499. return this._rows;
  14500. },
  14501. set: function (value) {
  14502. var _this = this;
  14503. if (this._rows === value) {
  14504. return;
  14505. }
  14506. this._rows = value;
  14507. this._rowThenColum = false;
  14508. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14509. _this._arrangeChildren();
  14510. });
  14511. },
  14512. enumerable: true,
  14513. configurable: true
  14514. });
  14515. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14516. this._cellWidth = 0;
  14517. this._cellHeight = 0;
  14518. var rows = 0;
  14519. var columns = 0;
  14520. var controlCount = 0;
  14521. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14522. // Measure
  14523. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14524. var child = _a[_i];
  14525. if (!child.mesh) {
  14526. continue;
  14527. }
  14528. controlCount++;
  14529. child.mesh.computeWorldMatrix(true);
  14530. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14531. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14532. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14533. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14534. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14535. diff.scaleInPlace(0.5);
  14536. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14537. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14538. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14539. }
  14540. this._cellWidth += this.margin * 2;
  14541. this._cellHeight += this.margin * 2;
  14542. // Arrange
  14543. if (this._rowThenColum) {
  14544. columns = this._columns;
  14545. rows = Math.ceil(controlCount / this._columns);
  14546. }
  14547. else {
  14548. rows = this._rows;
  14549. columns = Math.ceil(controlCount / this._rows);
  14550. }
  14551. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14552. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14553. var nodeGrid = [];
  14554. var cellCounter = 0;
  14555. if (this._rowThenColum) {
  14556. for (var r = 0; r < rows; r++) {
  14557. for (var c = 0; c < columns; c++) {
  14558. 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));
  14559. cellCounter++;
  14560. if (cellCounter > controlCount) {
  14561. break;
  14562. }
  14563. }
  14564. }
  14565. }
  14566. else {
  14567. for (var c = 0; c < columns; c++) {
  14568. for (var r = 0; r < rows; r++) {
  14569. 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));
  14570. cellCounter++;
  14571. if (cellCounter > controlCount) {
  14572. break;
  14573. }
  14574. }
  14575. }
  14576. }
  14577. cellCounter = 0;
  14578. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14579. var child = _c[_b];
  14580. if (!child.mesh) {
  14581. continue;
  14582. }
  14583. this._mapGridNode(child, nodeGrid[cellCounter]);
  14584. cellCounter++;
  14585. }
  14586. this._finalProcessing();
  14587. };
  14588. /** Child classes can implement this function to provide additional processing */
  14589. VolumeBasedPanel.prototype._finalProcessing = function () {
  14590. };
  14591. return VolumeBasedPanel;
  14592. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14593. /***/ }),
  14594. /***/ "./3D/gui3DManager.ts":
  14595. /*!****************************!*\
  14596. !*** ./3D/gui3DManager.ts ***!
  14597. \****************************/
  14598. /*! exports provided: GUI3DManager */
  14599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14600. "use strict";
  14601. __webpack_require__.r(__webpack_exports__);
  14602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14603. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  14604. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14605. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14606. /**
  14607. * Class used to manage 3D user interface
  14608. * @see http://doc.babylonjs.com/how_to/gui3d
  14609. */
  14610. var GUI3DManager = /** @class */ (function () {
  14611. /**
  14612. * Creates a new GUI3DManager
  14613. * @param scene
  14614. */
  14615. function GUI3DManager(scene) {
  14616. var _this = this;
  14617. /** @hidden */
  14618. this._lastControlOver = {};
  14619. /** @hidden */
  14620. this._lastControlDown = {};
  14621. /**
  14622. * Observable raised when the point picked by the pointer events changed
  14623. */
  14624. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14625. // Shared resources
  14626. /** @hidden */
  14627. this._sharedMaterials = {};
  14628. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14629. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14630. _this._sceneDisposeObserver = null;
  14631. _this._utilityLayer = null;
  14632. _this.dispose();
  14633. });
  14634. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14635. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14636. this._utilityLayer.pickUtilitySceneFirst = false;
  14637. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14638. return mesh && mesh.metadata && mesh.metadata._node;
  14639. };
  14640. // Root
  14641. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14642. this._rootContainer._host = this;
  14643. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14644. // Events
  14645. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14646. _this._handlePointerOut(pointerId, true);
  14647. });
  14648. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14649. _this._doPicking(pi);
  14650. });
  14651. // Scene
  14652. this._utilityLayer.utilityLayerScene.autoClear = false;
  14653. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14654. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14655. }
  14656. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14657. /** Gets the hosting scene */
  14658. get: function () {
  14659. return this._scene;
  14660. },
  14661. enumerable: true,
  14662. configurable: true
  14663. });
  14664. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14665. /** Gets associated utility layer */
  14666. get: function () {
  14667. return this._utilityLayer;
  14668. },
  14669. enumerable: true,
  14670. configurable: true
  14671. });
  14672. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14673. var previousControlOver = this._lastControlOver[pointerId];
  14674. if (previousControlOver) {
  14675. previousControlOver._onPointerOut(previousControlOver);
  14676. delete this._lastControlOver[pointerId];
  14677. }
  14678. if (isPointerUp) {
  14679. if (this._lastControlDown[pointerId]) {
  14680. this._lastControlDown[pointerId].forcePointerUp();
  14681. delete this._lastControlDown[pointerId];
  14682. }
  14683. }
  14684. this.onPickedPointChangedObservable.notifyObservers(null);
  14685. };
  14686. GUI3DManager.prototype._doPicking = function (pi) {
  14687. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14688. return false;
  14689. }
  14690. var pointerEvent = (pi.event);
  14691. var pointerId = pointerEvent.pointerId || 0;
  14692. var buttonIndex = pointerEvent.button;
  14693. var pickingInfo = pi.pickInfo;
  14694. if (!pickingInfo || !pickingInfo.hit) {
  14695. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14696. return false;
  14697. }
  14698. var control = (pickingInfo.pickedMesh.metadata);
  14699. if (pickingInfo.pickedPoint) {
  14700. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14701. }
  14702. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14703. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14704. if (this._lastControlOver[pointerId]) {
  14705. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14706. }
  14707. delete this._lastControlOver[pointerId];
  14708. }
  14709. }
  14710. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14711. if (this._lastControlDown[pointerEvent.pointerId]) {
  14712. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14713. delete this._lastControlDown[pointerEvent.pointerId];
  14714. }
  14715. if (pointerEvent.pointerType === "touch") {
  14716. this._handlePointerOut(pointerId, false);
  14717. }
  14718. }
  14719. return true;
  14720. };
  14721. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14722. /**
  14723. * Gets the root container
  14724. */
  14725. get: function () {
  14726. return this._rootContainer;
  14727. },
  14728. enumerable: true,
  14729. configurable: true
  14730. });
  14731. /**
  14732. * Gets a boolean indicating if the given control is in the root child list
  14733. * @param control defines the control to check
  14734. * @returns true if the control is in the root child list
  14735. */
  14736. GUI3DManager.prototype.containsControl = function (control) {
  14737. return this._rootContainer.containsControl(control);
  14738. };
  14739. /**
  14740. * Adds a control to the root child list
  14741. * @param control defines the control to add
  14742. * @returns the current manager
  14743. */
  14744. GUI3DManager.prototype.addControl = function (control) {
  14745. this._rootContainer.addControl(control);
  14746. return this;
  14747. };
  14748. /**
  14749. * Removes a control from the root child list
  14750. * @param control defines the control to remove
  14751. * @returns the current container
  14752. */
  14753. GUI3DManager.prototype.removeControl = function (control) {
  14754. this._rootContainer.removeControl(control);
  14755. return this;
  14756. };
  14757. /**
  14758. * Releases all associated resources
  14759. */
  14760. GUI3DManager.prototype.dispose = function () {
  14761. this._rootContainer.dispose();
  14762. for (var materialName in this._sharedMaterials) {
  14763. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14764. continue;
  14765. }
  14766. this._sharedMaterials[materialName].dispose();
  14767. }
  14768. this._sharedMaterials = {};
  14769. if (this._pointerOutObserver && this._utilityLayer) {
  14770. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14771. this._pointerOutObserver = null;
  14772. }
  14773. this.onPickedPointChangedObservable.clear();
  14774. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14775. if (utilityLayerScene) {
  14776. if (this._pointerObserver) {
  14777. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14778. this._pointerObserver = null;
  14779. }
  14780. }
  14781. if (this._scene) {
  14782. if (this._sceneDisposeObserver) {
  14783. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14784. this._sceneDisposeObserver = null;
  14785. }
  14786. }
  14787. if (this._utilityLayer) {
  14788. this._utilityLayer.dispose();
  14789. }
  14790. };
  14791. return GUI3DManager;
  14792. }());
  14793. /***/ }),
  14794. /***/ "./3D/index.ts":
  14795. /*!*********************!*\
  14796. !*** ./3D/index.ts ***!
  14797. \*********************/
  14798. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14800. "use strict";
  14801. __webpack_require__.r(__webpack_exports__);
  14802. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14815. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14818. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14820. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14822. /***/ }),
  14823. /***/ "./3D/materials/fluentMaterial.ts":
  14824. /*!****************************************!*\
  14825. !*** ./3D/materials/fluentMaterial.ts ***!
  14826. \****************************************/
  14827. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14829. "use strict";
  14830. __webpack_require__.r(__webpack_exports__);
  14831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14833. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14834. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  14835. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14836. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14837. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14838. /** @hidden */
  14839. var FluentMaterialDefines = /** @class */ (function (_super) {
  14840. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14841. function FluentMaterialDefines() {
  14842. var _this = _super.call(this) || this;
  14843. _this.INNERGLOW = false;
  14844. _this.BORDER = false;
  14845. _this.HOVERLIGHT = false;
  14846. _this.TEXTURE = false;
  14847. _this.rebuild();
  14848. return _this;
  14849. }
  14850. return FluentMaterialDefines;
  14851. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14852. /**
  14853. * Class used to render controls with fluent desgin
  14854. */
  14855. var FluentMaterial = /** @class */ (function (_super) {
  14856. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14857. /**
  14858. * Creates a new Fluent material
  14859. * @param name defines the name of the material
  14860. * @param scene defines the hosting scene
  14861. */
  14862. function FluentMaterial(name, scene) {
  14863. var _this = _super.call(this, name, scene) || this;
  14864. /**
  14865. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14866. */
  14867. _this.innerGlowColorIntensity = 0.5;
  14868. /**
  14869. * Gets or sets the inner glow color (white by default)
  14870. */
  14871. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14872. /**
  14873. * Gets or sets alpha value (default is 1.0)
  14874. */
  14875. _this.alpha = 1.0;
  14876. /**
  14877. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14878. */
  14879. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14880. /**
  14881. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14882. */
  14883. _this.renderBorders = false;
  14884. /**
  14885. * Gets or sets border width (default is 0.5)
  14886. */
  14887. _this.borderWidth = 0.5;
  14888. /**
  14889. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14890. */
  14891. _this.edgeSmoothingValue = 0.02;
  14892. /**
  14893. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14894. */
  14895. _this.borderMinValue = 0.1;
  14896. /**
  14897. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14898. */
  14899. _this.renderHoverLight = false;
  14900. /**
  14901. * Gets or sets the radius used to render the hover light (default is 1.0)
  14902. */
  14903. _this.hoverRadius = 1.0;
  14904. /**
  14905. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14906. */
  14907. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14908. /**
  14909. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14910. */
  14911. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14912. return _this;
  14913. }
  14914. FluentMaterial.prototype.needAlphaBlending = function () {
  14915. return this.alpha !== 1.0;
  14916. };
  14917. FluentMaterial.prototype.needAlphaTesting = function () {
  14918. return false;
  14919. };
  14920. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14921. return null;
  14922. };
  14923. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14924. if (this.isFrozen) {
  14925. if (this._wasPreviouslyReady && subMesh.effect) {
  14926. return true;
  14927. }
  14928. }
  14929. if (!subMesh._materialDefines) {
  14930. subMesh._materialDefines = new FluentMaterialDefines();
  14931. }
  14932. var scene = this.getScene();
  14933. var defines = subMesh._materialDefines;
  14934. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14935. if (defines._renderId === scene.getRenderId()) {
  14936. return true;
  14937. }
  14938. }
  14939. if (defines._areTexturesDirty) {
  14940. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14941. defines.BORDER = this.renderBorders;
  14942. defines.HOVERLIGHT = this.renderHoverLight;
  14943. if (this._albedoTexture) {
  14944. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14945. return false;
  14946. }
  14947. else {
  14948. defines.TEXTURE = true;
  14949. }
  14950. }
  14951. else {
  14952. defines.TEXTURE = false;
  14953. }
  14954. }
  14955. var engine = scene.getEngine();
  14956. // Get correct effect
  14957. if (defines.isDirty) {
  14958. defines.markAsProcessed();
  14959. scene.resetCachedMaterial();
  14960. //Attributes
  14961. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14962. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14963. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14964. var shaderName = "fluent";
  14965. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14966. "hoverColor", "hoverPosition", "hoverRadius"
  14967. ];
  14968. var samplers = ["albedoSampler"];
  14969. var uniformBuffers = new Array();
  14970. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14971. uniformsNames: uniforms,
  14972. uniformBuffersNames: uniformBuffers,
  14973. samplers: samplers,
  14974. defines: defines,
  14975. maxSimultaneousLights: 4
  14976. });
  14977. var join = defines.toString();
  14978. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14979. attributes: attribs,
  14980. uniformsNames: uniforms,
  14981. uniformBuffersNames: uniformBuffers,
  14982. samplers: samplers,
  14983. defines: join,
  14984. fallbacks: null,
  14985. onCompiled: this.onCompiled,
  14986. onError: this.onError,
  14987. indexParameters: { maxSimultaneousLights: 4 }
  14988. }, engine));
  14989. }
  14990. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14991. return false;
  14992. }
  14993. defines._renderId = scene.getRenderId();
  14994. this._wasPreviouslyReady = true;
  14995. return true;
  14996. };
  14997. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14998. var scene = this.getScene();
  14999. var defines = subMesh._materialDefines;
  15000. if (!defines) {
  15001. return;
  15002. }
  15003. var effect = subMesh.effect;
  15004. if (!effect) {
  15005. return;
  15006. }
  15007. this._activeEffect = effect;
  15008. // Matrices
  15009. this.bindOnlyWorldMatrix(world);
  15010. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15011. if (this._mustRebind(scene, effect)) {
  15012. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15013. if (defines.INNERGLOW) {
  15014. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15015. }
  15016. if (defines.BORDER) {
  15017. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15018. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15019. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15020. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15021. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15022. }
  15023. if (defines.HOVERLIGHT) {
  15024. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15025. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15026. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15027. }
  15028. if (defines.TEXTURE) {
  15029. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15030. }
  15031. }
  15032. this._afterBind(mesh, this._activeEffect);
  15033. };
  15034. FluentMaterial.prototype.getActiveTextures = function () {
  15035. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15036. return activeTextures;
  15037. };
  15038. FluentMaterial.prototype.hasTexture = function (texture) {
  15039. if (_super.prototype.hasTexture.call(this, texture)) {
  15040. return true;
  15041. }
  15042. return false;
  15043. };
  15044. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15045. _super.prototype.dispose.call(this, forceDisposeEffect);
  15046. };
  15047. FluentMaterial.prototype.clone = function (name) {
  15048. var _this = this;
  15049. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15050. };
  15051. FluentMaterial.prototype.serialize = function () {
  15052. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15053. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15054. return serializationObject;
  15055. };
  15056. FluentMaterial.prototype.getClassName = function () {
  15057. return "FluentMaterial";
  15058. };
  15059. // Statics
  15060. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15061. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15062. };
  15063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15064. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15065. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15066. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15068. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15069. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15071. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15072. ], FluentMaterial.prototype, "alpha", void 0);
  15073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15074. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15075. ], FluentMaterial.prototype, "albedoColor", void 0);
  15076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15077. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15078. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15079. ], FluentMaterial.prototype, "renderBorders", void 0);
  15080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15081. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15082. ], FluentMaterial.prototype, "borderWidth", void 0);
  15083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15084. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15085. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15087. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15088. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15090. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15091. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15092. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15094. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15095. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15097. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15098. ], FluentMaterial.prototype, "hoverColor", void 0);
  15099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15100. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15101. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15103. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15104. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15106. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15107. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15108. return FluentMaterial;
  15109. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15110. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15111. /***/ }),
  15112. /***/ "./3D/materials/index.ts":
  15113. /*!*******************************!*\
  15114. !*** ./3D/materials/index.ts ***!
  15115. \*******************************/
  15116. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15118. "use strict";
  15119. __webpack_require__.r(__webpack_exports__);
  15120. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15123. /***/ }),
  15124. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15125. /*!*************************************************!*\
  15126. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15127. \*************************************************/
  15128. /*! exports provided: fluentPixelShader */
  15129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15130. "use strict";
  15131. __webpack_require__.r(__webpack_exports__);
  15132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15133. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15134. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15135. var name = 'fluentPixelShader';
  15136. 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}";
  15137. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15138. /** @hidden */
  15139. var fluentPixelShader = { name: name, shader: shader };
  15140. /***/ }),
  15141. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15142. /*!***********************************************!*\
  15143. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15144. \***********************************************/
  15145. /*! exports provided: fluentVertexShader */
  15146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15147. "use strict";
  15148. __webpack_require__.r(__webpack_exports__);
  15149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15150. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15151. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15152. var name = 'fluentVertexShader';
  15153. 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";
  15154. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15155. /** @hidden */
  15156. var fluentVertexShader = { name: name, shader: shader };
  15157. /***/ }),
  15158. /***/ "./3D/vector3WithInfo.ts":
  15159. /*!*******************************!*\
  15160. !*** ./3D/vector3WithInfo.ts ***!
  15161. \*******************************/
  15162. /*! exports provided: Vector3WithInfo */
  15163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15164. "use strict";
  15165. __webpack_require__.r(__webpack_exports__);
  15166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15167. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15168. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  15169. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15170. /**
  15171. * Class used to transport Vector3 information for pointer events
  15172. */
  15173. var Vector3WithInfo = /** @class */ (function (_super) {
  15174. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  15175. /**
  15176. * Creates a new Vector3WithInfo
  15177. * @param source defines the vector3 data to transport
  15178. * @param buttonIndex defines the current mouse button index
  15179. */
  15180. function Vector3WithInfo(source,
  15181. /** defines the current mouse button index */
  15182. buttonIndex) {
  15183. if (buttonIndex === void 0) { buttonIndex = 0; }
  15184. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15185. _this.buttonIndex = buttonIndex;
  15186. return _this;
  15187. }
  15188. return Vector3WithInfo;
  15189. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15190. /***/ }),
  15191. /***/ "./index.ts":
  15192. /*!******************!*\
  15193. !*** ./index.ts ***!
  15194. \******************/
  15195. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15197. "use strict";
  15198. __webpack_require__.r(__webpack_exports__);
  15199. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15240. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  15249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  15250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  15251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  15252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  15253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  15254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  15255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15257. /***/ }),
  15258. /***/ "./legacy/legacy.ts":
  15259. /*!**************************!*\
  15260. !*** ./legacy/legacy.ts ***!
  15261. \**************************/
  15262. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15263. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15264. "use strict";
  15265. __webpack_require__.r(__webpack_exports__);
  15266. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  15267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  15277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  15278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15323. /**
  15324. * Legacy support, defining window.BABYLON.GUI (global variable).
  15325. *
  15326. * This is the entry point for the UMD module.
  15327. * The entry point for a future ESM package should be index.ts
  15328. */
  15329. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  15330. if (typeof globalObject !== "undefined") {
  15331. globalObject.BABYLON = globalObject.BABYLON || {};
  15332. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  15333. }
  15334. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  15335. /***/ }),
  15336. /***/ "babylonjs/Maths/math":
  15337. /*!****************************************************************************************************!*\
  15338. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  15339. \****************************************************************************************************/
  15340. /*! no static exports found */
  15341. /***/ (function(module, exports) {
  15342. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  15343. /***/ })
  15344. /******/ });
  15345. });
  15346. //# sourceMappingURL=babylon.gui.js.map