babylon.gui.js 720 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561
  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. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  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._rootElement = scene.getEngine().getInputElement();
  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._rootElement = 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._rootElement) {
  1064. this._rootElement.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. Object(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. Object(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, invalidatedRectangle) {
  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. Object(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. Object(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. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3468. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3469. if (!this.children) {
  3470. return;
  3471. }
  3472. for (var index = 0; index < this.children.length; index++) {
  3473. var item = this.children[index];
  3474. if (!predicate || predicate(item)) {
  3475. results.push(item);
  3476. }
  3477. if (!directDescendantsOnly) {
  3478. item.getDescendantsToRef(results, false, predicate);
  3479. }
  3480. }
  3481. };
  3482. /** @hidden */
  3483. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3484. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3485. return false;
  3486. }
  3487. if (!_super.prototype.contains.call(this, x, y)) {
  3488. return false;
  3489. }
  3490. // Checking backwards to pick closest first
  3491. for (var index = this._children.length - 1; index >= 0; index--) {
  3492. var child = this._children[index];
  3493. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3494. if (child.hoverCursor) {
  3495. this._host._changeCursor(child.hoverCursor);
  3496. }
  3497. return true;
  3498. }
  3499. }
  3500. if (!this.isHitTestVisible) {
  3501. return false;
  3502. }
  3503. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3504. };
  3505. /** @hidden */
  3506. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3507. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3508. this._measureForChildren.copyFrom(this._currentMeasure);
  3509. };
  3510. /** Releases associated resources */
  3511. Container.prototype.dispose = function () {
  3512. _super.prototype.dispose.call(this);
  3513. for (var index = this.children.length - 1; index >= 0; index--) {
  3514. this.children[index].dispose();
  3515. }
  3516. };
  3517. return Container;
  3518. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3519. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3520. /***/ }),
  3521. /***/ "./2D/controls/control.ts":
  3522. /*!********************************!*\
  3523. !*** ./2D/controls/control.ts ***!
  3524. \********************************/
  3525. /*! exports provided: Control */
  3526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3527. "use strict";
  3528. __webpack_require__.r(__webpack_exports__);
  3529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3530. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3531. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3532. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3533. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3534. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3535. /**
  3536. * Root class used for all 2D controls
  3537. * @see http://doc.babylonjs.com/how_to/gui#controls
  3538. */
  3539. var Control = /** @class */ (function () {
  3540. // Functions
  3541. /**
  3542. * Creates a new control
  3543. * @param name defines the name of the control
  3544. */
  3545. function Control(
  3546. /** defines the name of the control */
  3547. name) {
  3548. this.name = name;
  3549. this._alpha = 1;
  3550. this._alphaSet = false;
  3551. this._zIndex = 0;
  3552. /** @hidden */
  3553. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3554. this._fontFamily = "Arial";
  3555. this._fontStyle = "";
  3556. this._fontWeight = "";
  3557. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3558. /** @hidden */
  3559. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3560. /** @hidden */
  3561. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3562. this._color = "";
  3563. this._style = null;
  3564. /** @hidden */
  3565. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3566. /** @hidden */
  3567. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3568. /** @hidden */
  3569. this._isDirty = true;
  3570. /** @hidden */
  3571. this._wasDirty = false;
  3572. /** @hidden */
  3573. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3574. /** @hidden */
  3575. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3576. /** @hidden */
  3577. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3578. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3579. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3580. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3582. /** @hidden */
  3583. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3584. /** @hidden */
  3585. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3586. this._scaleX = 1.0;
  3587. this._scaleY = 1.0;
  3588. this._rotation = 0;
  3589. this._transformCenterX = 0.5;
  3590. this._transformCenterY = 0.5;
  3591. /** @hidden */
  3592. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3593. /** @hidden */
  3594. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3595. /** @hidden */
  3596. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3597. this._isMatrixDirty = true;
  3598. this._isVisible = true;
  3599. this._isHighlighted = false;
  3600. this._fontSet = false;
  3601. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3602. this._downCount = 0;
  3603. this._enterCount = -1;
  3604. this._doNotRender = false;
  3605. this._downPointerIds = {};
  3606. this._isEnabled = true;
  3607. this._disabledColor = "#9a9a9a";
  3608. /** @hidden */
  3609. this._rebuildLayout = false;
  3610. /** @hidden */
  3611. this._isClipped = false;
  3612. /** @hidden */
  3613. this._automaticSize = false;
  3614. /**
  3615. * Gets or sets an object used to store user defined information for the node
  3616. */
  3617. this.metadata = null;
  3618. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3619. this.isHitTestVisible = true;
  3620. /** Gets or sets a boolean indicating if the control can block pointer events */
  3621. this.isPointerBlocker = false;
  3622. /** Gets or sets a boolean indicating if the control can be focusable */
  3623. this.isFocusInvisible = false;
  3624. /**
  3625. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3626. * 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
  3627. */
  3628. this.clipChildren = true;
  3629. /**
  3630. * Gets or sets a boolean indicating that control content must be clipped
  3631. * 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
  3632. */
  3633. this.clipContent = true;
  3634. /**
  3635. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3636. */
  3637. this.useBitmapCache = false;
  3638. this._shadowOffsetX = 0;
  3639. this._shadowOffsetY = 0;
  3640. this._shadowBlur = 0;
  3641. this._shadowColor = 'black';
  3642. /** Gets or sets the cursor to use when the control is hovered */
  3643. this.hoverCursor = "";
  3644. /** @hidden */
  3645. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3646. /** @hidden */
  3647. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3648. /**
  3649. * An event triggered when the pointer move over the control.
  3650. */
  3651. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3652. /**
  3653. * An event triggered when the pointer move out of the control.
  3654. */
  3655. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3656. /**
  3657. * An event triggered when the pointer taps the control
  3658. */
  3659. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3660. /**
  3661. * An event triggered when pointer up
  3662. */
  3663. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3664. /**
  3665. * An event triggered when a control is clicked on
  3666. */
  3667. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3668. /**
  3669. * An event triggered when pointer enters the control
  3670. */
  3671. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3672. /**
  3673. * An event triggered when the control is marked as dirty
  3674. */
  3675. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3676. /**
  3677. * An event triggered before drawing the control
  3678. */
  3679. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3680. /**
  3681. * An event triggered after the control was drawn
  3682. */
  3683. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3684. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3685. }
  3686. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3687. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3688. get: function () {
  3689. return this._shadowOffsetX;
  3690. },
  3691. set: function (value) {
  3692. if (this._shadowOffsetX === value) {
  3693. return;
  3694. }
  3695. this._shadowOffsetX = value;
  3696. this._markAsDirty();
  3697. },
  3698. enumerable: true,
  3699. configurable: true
  3700. });
  3701. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3702. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3703. get: function () {
  3704. return this._shadowOffsetY;
  3705. },
  3706. set: function (value) {
  3707. if (this._shadowOffsetY === value) {
  3708. return;
  3709. }
  3710. this._shadowOffsetY = value;
  3711. this._markAsDirty();
  3712. },
  3713. enumerable: true,
  3714. configurable: true
  3715. });
  3716. Object.defineProperty(Control.prototype, "shadowBlur", {
  3717. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3718. get: function () {
  3719. return this._shadowBlur;
  3720. },
  3721. set: function (value) {
  3722. if (this._shadowBlur === value) {
  3723. return;
  3724. }
  3725. this._shadowBlur = value;
  3726. this._markAsDirty();
  3727. },
  3728. enumerable: true,
  3729. configurable: true
  3730. });
  3731. Object.defineProperty(Control.prototype, "shadowColor", {
  3732. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3733. get: function () {
  3734. return this._shadowColor;
  3735. },
  3736. set: function (value) {
  3737. if (this._shadowColor === value) {
  3738. return;
  3739. }
  3740. this._shadowColor = value;
  3741. this._markAsDirty();
  3742. },
  3743. enumerable: true,
  3744. configurable: true
  3745. });
  3746. Object.defineProperty(Control.prototype, "typeName", {
  3747. // Properties
  3748. /** Gets the control type name */
  3749. get: function () {
  3750. return this._getTypeName();
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. /**
  3756. * Get the current class name of the control.
  3757. * @returns current class name
  3758. */
  3759. Control.prototype.getClassName = function () {
  3760. return this._getTypeName();
  3761. };
  3762. Object.defineProperty(Control.prototype, "host", {
  3763. /**
  3764. * Get the hosting AdvancedDynamicTexture
  3765. */
  3766. get: function () {
  3767. return this._host;
  3768. },
  3769. enumerable: true,
  3770. configurable: true
  3771. });
  3772. Object.defineProperty(Control.prototype, "fontOffset", {
  3773. /** Gets or set information about font offsets (used to render and align text) */
  3774. get: function () {
  3775. return this._fontOffset;
  3776. },
  3777. set: function (offset) {
  3778. this._fontOffset = offset;
  3779. },
  3780. enumerable: true,
  3781. configurable: true
  3782. });
  3783. Object.defineProperty(Control.prototype, "alpha", {
  3784. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3785. get: function () {
  3786. return this._alpha;
  3787. },
  3788. set: function (value) {
  3789. if (this._alpha === value) {
  3790. return;
  3791. }
  3792. this._alphaSet = true;
  3793. this._alpha = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "isHighlighted", {
  3800. /**
  3801. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3802. */
  3803. get: function () {
  3804. return this._isHighlighted;
  3805. },
  3806. set: function (value) {
  3807. if (this._isHighlighted === value) {
  3808. return;
  3809. }
  3810. this._isHighlighted = value;
  3811. this._markAsDirty();
  3812. },
  3813. enumerable: true,
  3814. configurable: true
  3815. });
  3816. Object.defineProperty(Control.prototype, "scaleX", {
  3817. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3818. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3819. */
  3820. get: function () {
  3821. return this._scaleX;
  3822. },
  3823. set: function (value) {
  3824. if (this._scaleX === value) {
  3825. return;
  3826. }
  3827. this._scaleX = value;
  3828. this._markAsDirty();
  3829. this._markMatrixAsDirty();
  3830. },
  3831. enumerable: true,
  3832. configurable: true
  3833. });
  3834. Object.defineProperty(Control.prototype, "scaleY", {
  3835. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3836. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3837. */
  3838. get: function () {
  3839. return this._scaleY;
  3840. },
  3841. set: function (value) {
  3842. if (this._scaleY === value) {
  3843. return;
  3844. }
  3845. this._scaleY = value;
  3846. this._markAsDirty();
  3847. this._markMatrixAsDirty();
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Control.prototype, "rotation", {
  3853. /** Gets or sets the rotation angle (0 by default)
  3854. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3855. */
  3856. get: function () {
  3857. return this._rotation;
  3858. },
  3859. set: function (value) {
  3860. if (this._rotation === value) {
  3861. return;
  3862. }
  3863. this._rotation = value;
  3864. this._markAsDirty();
  3865. this._markMatrixAsDirty();
  3866. },
  3867. enumerable: true,
  3868. configurable: true
  3869. });
  3870. Object.defineProperty(Control.prototype, "transformCenterY", {
  3871. /** Gets or sets the transformation center on Y axis (0 by default)
  3872. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3873. */
  3874. get: function () {
  3875. return this._transformCenterY;
  3876. },
  3877. set: function (value) {
  3878. if (this._transformCenterY === value) {
  3879. return;
  3880. }
  3881. this._transformCenterY = value;
  3882. this._markAsDirty();
  3883. this._markMatrixAsDirty();
  3884. },
  3885. enumerable: true,
  3886. configurable: true
  3887. });
  3888. Object.defineProperty(Control.prototype, "transformCenterX", {
  3889. /** Gets or sets the transformation center on X axis (0 by default)
  3890. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3891. */
  3892. get: function () {
  3893. return this._transformCenterX;
  3894. },
  3895. set: function (value) {
  3896. if (this._transformCenterX === value) {
  3897. return;
  3898. }
  3899. this._transformCenterX = value;
  3900. this._markAsDirty();
  3901. this._markMatrixAsDirty();
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3907. /**
  3908. * Gets or sets the horizontal alignment
  3909. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3910. */
  3911. get: function () {
  3912. return this._horizontalAlignment;
  3913. },
  3914. set: function (value) {
  3915. if (this._horizontalAlignment === value) {
  3916. return;
  3917. }
  3918. this._horizontalAlignment = value;
  3919. this._markAsDirty();
  3920. },
  3921. enumerable: true,
  3922. configurable: true
  3923. });
  3924. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3925. /**
  3926. * Gets or sets the vertical alignment
  3927. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3928. */
  3929. get: function () {
  3930. return this._verticalAlignment;
  3931. },
  3932. set: function (value) {
  3933. if (this._verticalAlignment === value) {
  3934. return;
  3935. }
  3936. this._verticalAlignment = value;
  3937. this._markAsDirty();
  3938. },
  3939. enumerable: true,
  3940. configurable: true
  3941. });
  3942. Object.defineProperty(Control.prototype, "width", {
  3943. /**
  3944. * Gets or sets control width
  3945. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3946. */
  3947. get: function () {
  3948. return this._width.toString(this._host);
  3949. },
  3950. set: function (value) {
  3951. if (this._width.toString(this._host) === value) {
  3952. return;
  3953. }
  3954. if (this._width.fromString(value)) {
  3955. this._markAsDirty();
  3956. }
  3957. },
  3958. enumerable: true,
  3959. configurable: true
  3960. });
  3961. Object.defineProperty(Control.prototype, "widthInPixels", {
  3962. /**
  3963. * Gets or sets the control width in pixel
  3964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3965. */
  3966. get: function () {
  3967. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3968. },
  3969. set: function (value) {
  3970. if (isNaN(value)) {
  3971. return;
  3972. }
  3973. this.width = value + "px";
  3974. },
  3975. enumerable: true,
  3976. configurable: true
  3977. });
  3978. Object.defineProperty(Control.prototype, "height", {
  3979. /**
  3980. * Gets or sets control height
  3981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3982. */
  3983. get: function () {
  3984. return this._height.toString(this._host);
  3985. },
  3986. set: function (value) {
  3987. if (this._height.toString(this._host) === value) {
  3988. return;
  3989. }
  3990. if (this._height.fromString(value)) {
  3991. this._markAsDirty();
  3992. }
  3993. },
  3994. enumerable: true,
  3995. configurable: true
  3996. });
  3997. Object.defineProperty(Control.prototype, "heightInPixels", {
  3998. /**
  3999. * Gets or sets control height in pixel
  4000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4001. */
  4002. get: function () {
  4003. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4004. },
  4005. set: function (value) {
  4006. if (isNaN(value)) {
  4007. return;
  4008. }
  4009. this.height = value + "px";
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "fontFamily", {
  4015. /** Gets or set font family */
  4016. get: function () {
  4017. if (!this._fontSet) {
  4018. return "";
  4019. }
  4020. return this._fontFamily;
  4021. },
  4022. set: function (value) {
  4023. if (this._fontFamily === value) {
  4024. return;
  4025. }
  4026. this._fontFamily = value;
  4027. this._resetFontCache();
  4028. },
  4029. enumerable: true,
  4030. configurable: true
  4031. });
  4032. Object.defineProperty(Control.prototype, "fontStyle", {
  4033. /** Gets or sets font style */
  4034. get: function () {
  4035. return this._fontStyle;
  4036. },
  4037. set: function (value) {
  4038. if (this._fontStyle === value) {
  4039. return;
  4040. }
  4041. this._fontStyle = value;
  4042. this._resetFontCache();
  4043. },
  4044. enumerable: true,
  4045. configurable: true
  4046. });
  4047. Object.defineProperty(Control.prototype, "fontWeight", {
  4048. /** Gets or sets font weight */
  4049. get: function () {
  4050. return this._fontWeight;
  4051. },
  4052. set: function (value) {
  4053. if (this._fontWeight === value) {
  4054. return;
  4055. }
  4056. this._fontWeight = value;
  4057. this._resetFontCache();
  4058. },
  4059. enumerable: true,
  4060. configurable: true
  4061. });
  4062. Object.defineProperty(Control.prototype, "style", {
  4063. /**
  4064. * Gets or sets style
  4065. * @see http://doc.babylonjs.com/how_to/gui#styles
  4066. */
  4067. get: function () {
  4068. return this._style;
  4069. },
  4070. set: function (value) {
  4071. var _this = this;
  4072. if (this._style) {
  4073. this._style.onChangedObservable.remove(this._styleObserver);
  4074. this._styleObserver = null;
  4075. }
  4076. this._style = value;
  4077. if (this._style) {
  4078. this._styleObserver = this._style.onChangedObservable.add(function () {
  4079. _this._markAsDirty();
  4080. _this._resetFontCache();
  4081. });
  4082. }
  4083. this._markAsDirty();
  4084. this._resetFontCache();
  4085. },
  4086. enumerable: true,
  4087. configurable: true
  4088. });
  4089. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4090. /** @hidden */
  4091. get: function () {
  4092. return this._fontSize.isPercentage;
  4093. },
  4094. enumerable: true,
  4095. configurable: true
  4096. });
  4097. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4098. /** Gets or sets font size in pixels */
  4099. get: function () {
  4100. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4101. if (fontSizeToUse.isPixel) {
  4102. return fontSizeToUse.getValue(this._host);
  4103. }
  4104. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4105. },
  4106. set: function (value) {
  4107. if (isNaN(value)) {
  4108. return;
  4109. }
  4110. this.fontSize = value + "px";
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "fontSize", {
  4116. /** Gets or sets font size */
  4117. get: function () {
  4118. return this._fontSize.toString(this._host);
  4119. },
  4120. set: function (value) {
  4121. if (this._fontSize.toString(this._host) === value) {
  4122. return;
  4123. }
  4124. if (this._fontSize.fromString(value)) {
  4125. this._markAsDirty();
  4126. this._resetFontCache();
  4127. }
  4128. },
  4129. enumerable: true,
  4130. configurable: true
  4131. });
  4132. Object.defineProperty(Control.prototype, "color", {
  4133. /** Gets or sets foreground color */
  4134. get: function () {
  4135. return this._color;
  4136. },
  4137. set: function (value) {
  4138. if (this._color === value) {
  4139. return;
  4140. }
  4141. this._color = value;
  4142. this._markAsDirty();
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(Control.prototype, "zIndex", {
  4148. /** Gets or sets z index which is used to reorder controls on the z axis */
  4149. get: function () {
  4150. return this._zIndex;
  4151. },
  4152. set: function (value) {
  4153. if (this.zIndex === value) {
  4154. return;
  4155. }
  4156. this._zIndex = value;
  4157. if (this.parent) {
  4158. this.parent._reOrderControl(this);
  4159. }
  4160. },
  4161. enumerable: true,
  4162. configurable: true
  4163. });
  4164. Object.defineProperty(Control.prototype, "notRenderable", {
  4165. /** Gets or sets a boolean indicating if the control can be rendered */
  4166. get: function () {
  4167. return this._doNotRender;
  4168. },
  4169. set: function (value) {
  4170. if (this._doNotRender === value) {
  4171. return;
  4172. }
  4173. this._doNotRender = value;
  4174. this._markAsDirty();
  4175. },
  4176. enumerable: true,
  4177. configurable: true
  4178. });
  4179. Object.defineProperty(Control.prototype, "isVisible", {
  4180. /** Gets or sets a boolean indicating if the control is visible */
  4181. get: function () {
  4182. return this._isVisible;
  4183. },
  4184. set: function (value) {
  4185. if (this._isVisible === value) {
  4186. return;
  4187. }
  4188. this._isVisible = value;
  4189. this._markAsDirty(true);
  4190. },
  4191. enumerable: true,
  4192. configurable: true
  4193. });
  4194. Object.defineProperty(Control.prototype, "isDirty", {
  4195. /** Gets a boolean indicating that the control needs to update its rendering */
  4196. get: function () {
  4197. return this._isDirty;
  4198. },
  4199. enumerable: true,
  4200. configurable: true
  4201. });
  4202. Object.defineProperty(Control.prototype, "linkedMesh", {
  4203. /**
  4204. * Gets the current linked mesh (or null if none)
  4205. */
  4206. get: function () {
  4207. return this._linkedMesh;
  4208. },
  4209. enumerable: true,
  4210. configurable: true
  4211. });
  4212. Object.defineProperty(Control.prototype, "paddingLeft", {
  4213. /**
  4214. * Gets or sets a value indicating the padding to use on the left of the control
  4215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4216. */
  4217. get: function () {
  4218. return this._paddingLeft.toString(this._host);
  4219. },
  4220. set: function (value) {
  4221. if (this._paddingLeft.fromString(value)) {
  4222. this._markAsDirty();
  4223. }
  4224. },
  4225. enumerable: true,
  4226. configurable: true
  4227. });
  4228. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4229. /**
  4230. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4232. */
  4233. get: function () {
  4234. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4235. },
  4236. set: function (value) {
  4237. if (isNaN(value)) {
  4238. return;
  4239. }
  4240. this.paddingLeft = value + "px";
  4241. },
  4242. enumerable: true,
  4243. configurable: true
  4244. });
  4245. Object.defineProperty(Control.prototype, "paddingRight", {
  4246. /**
  4247. * Gets or sets a value indicating the padding to use on the right of the control
  4248. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4249. */
  4250. get: function () {
  4251. return this._paddingRight.toString(this._host);
  4252. },
  4253. set: function (value) {
  4254. if (this._paddingRight.fromString(value)) {
  4255. this._markAsDirty();
  4256. }
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4262. /**
  4263. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4264. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4265. */
  4266. get: function () {
  4267. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4268. },
  4269. set: function (value) {
  4270. if (isNaN(value)) {
  4271. return;
  4272. }
  4273. this.paddingRight = value + "px";
  4274. },
  4275. enumerable: true,
  4276. configurable: true
  4277. });
  4278. Object.defineProperty(Control.prototype, "paddingTop", {
  4279. /**
  4280. * Gets or sets a value indicating the padding to use on the top of the control
  4281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4282. */
  4283. get: function () {
  4284. return this._paddingTop.toString(this._host);
  4285. },
  4286. set: function (value) {
  4287. if (this._paddingTop.fromString(value)) {
  4288. this._markAsDirty();
  4289. }
  4290. },
  4291. enumerable: true,
  4292. configurable: true
  4293. });
  4294. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4295. /**
  4296. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4298. */
  4299. get: function () {
  4300. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4301. },
  4302. set: function (value) {
  4303. if (isNaN(value)) {
  4304. return;
  4305. }
  4306. this.paddingTop = value + "px";
  4307. },
  4308. enumerable: true,
  4309. configurable: true
  4310. });
  4311. Object.defineProperty(Control.prototype, "paddingBottom", {
  4312. /**
  4313. * Gets or sets a value indicating the padding to use on the bottom of the control
  4314. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4315. */
  4316. get: function () {
  4317. return this._paddingBottom.toString(this._host);
  4318. },
  4319. set: function (value) {
  4320. if (this._paddingBottom.fromString(value)) {
  4321. this._markAsDirty();
  4322. }
  4323. },
  4324. enumerable: true,
  4325. configurable: true
  4326. });
  4327. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4328. /**
  4329. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4330. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4331. */
  4332. get: function () {
  4333. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4334. },
  4335. set: function (value) {
  4336. if (isNaN(value)) {
  4337. return;
  4338. }
  4339. this.paddingBottom = value + "px";
  4340. },
  4341. enumerable: true,
  4342. configurable: true
  4343. });
  4344. Object.defineProperty(Control.prototype, "left", {
  4345. /**
  4346. * Gets or sets a value indicating the left coordinate of the control
  4347. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4348. */
  4349. get: function () {
  4350. return this._left.toString(this._host);
  4351. },
  4352. set: function (value) {
  4353. if (this._left.fromString(value)) {
  4354. this._markAsDirty();
  4355. }
  4356. },
  4357. enumerable: true,
  4358. configurable: true
  4359. });
  4360. Object.defineProperty(Control.prototype, "leftInPixels", {
  4361. /**
  4362. * Gets or sets a value indicating the left coordinate in pixels of the control
  4363. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4364. */
  4365. get: function () {
  4366. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4367. },
  4368. set: function (value) {
  4369. if (isNaN(value)) {
  4370. return;
  4371. }
  4372. this.left = value + "px";
  4373. },
  4374. enumerable: true,
  4375. configurable: true
  4376. });
  4377. Object.defineProperty(Control.prototype, "top", {
  4378. /**
  4379. * Gets or sets a value indicating the top coordinate of the control
  4380. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4381. */
  4382. get: function () {
  4383. return this._top.toString(this._host);
  4384. },
  4385. set: function (value) {
  4386. if (this._top.fromString(value)) {
  4387. this._markAsDirty();
  4388. }
  4389. },
  4390. enumerable: true,
  4391. configurable: true
  4392. });
  4393. Object.defineProperty(Control.prototype, "topInPixels", {
  4394. /**
  4395. * Gets or sets a value indicating the top coordinate in pixels of the control
  4396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4397. */
  4398. get: function () {
  4399. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4400. },
  4401. set: function (value) {
  4402. if (isNaN(value)) {
  4403. return;
  4404. }
  4405. this.top = value + "px";
  4406. },
  4407. enumerable: true,
  4408. configurable: true
  4409. });
  4410. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4411. /**
  4412. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4413. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4414. */
  4415. get: function () {
  4416. return this._linkOffsetX.toString(this._host);
  4417. },
  4418. set: function (value) {
  4419. if (this._linkOffsetX.fromString(value)) {
  4420. this._markAsDirty();
  4421. }
  4422. },
  4423. enumerable: true,
  4424. configurable: true
  4425. });
  4426. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4427. /**
  4428. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4429. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4430. */
  4431. get: function () {
  4432. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4433. },
  4434. set: function (value) {
  4435. if (isNaN(value)) {
  4436. return;
  4437. }
  4438. this.linkOffsetX = value + "px";
  4439. },
  4440. enumerable: true,
  4441. configurable: true
  4442. });
  4443. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4444. /**
  4445. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4446. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4447. */
  4448. get: function () {
  4449. return this._linkOffsetY.toString(this._host);
  4450. },
  4451. set: function (value) {
  4452. if (this._linkOffsetY.fromString(value)) {
  4453. this._markAsDirty();
  4454. }
  4455. },
  4456. enumerable: true,
  4457. configurable: true
  4458. });
  4459. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4460. /**
  4461. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4462. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4463. */
  4464. get: function () {
  4465. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4466. },
  4467. set: function (value) {
  4468. if (isNaN(value)) {
  4469. return;
  4470. }
  4471. this.linkOffsetY = value + "px";
  4472. },
  4473. enumerable: true,
  4474. configurable: true
  4475. });
  4476. Object.defineProperty(Control.prototype, "centerX", {
  4477. /** Gets the center coordinate on X axis */
  4478. get: function () {
  4479. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4480. },
  4481. enumerable: true,
  4482. configurable: true
  4483. });
  4484. Object.defineProperty(Control.prototype, "centerY", {
  4485. /** Gets the center coordinate on Y axis */
  4486. get: function () {
  4487. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4488. },
  4489. enumerable: true,
  4490. configurable: true
  4491. });
  4492. Object.defineProperty(Control.prototype, "isEnabled", {
  4493. /** Gets or sets if control is Enabled*/
  4494. get: function () {
  4495. return this._isEnabled;
  4496. },
  4497. set: function (value) {
  4498. if (this._isEnabled === value) {
  4499. return;
  4500. }
  4501. this._isEnabled = value;
  4502. this._markAsDirty();
  4503. },
  4504. enumerable: true,
  4505. configurable: true
  4506. });
  4507. Object.defineProperty(Control.prototype, "disabledColor", {
  4508. /** Gets or sets background color of control if it's disabled*/
  4509. get: function () {
  4510. return this._disabledColor;
  4511. },
  4512. set: function (value) {
  4513. if (this._disabledColor === value) {
  4514. return;
  4515. }
  4516. this._disabledColor = value;
  4517. this._markAsDirty();
  4518. },
  4519. enumerable: true,
  4520. configurable: true
  4521. });
  4522. /** @hidden */
  4523. Control.prototype._getTypeName = function () {
  4524. return "Control";
  4525. };
  4526. /**
  4527. * Gets the first ascendant in the hierarchy of the given type
  4528. * @param className defines the required type
  4529. * @returns the ascendant or null if not found
  4530. */
  4531. Control.prototype.getAscendantOfClass = function (className) {
  4532. if (!this.parent) {
  4533. return null;
  4534. }
  4535. if (this.parent.getClassName() === className) {
  4536. return this.parent;
  4537. }
  4538. return this.parent.getAscendantOfClass(className);
  4539. };
  4540. /** @hidden */
  4541. Control.prototype._resetFontCache = function () {
  4542. this._fontSet = true;
  4543. this._markAsDirty();
  4544. };
  4545. /**
  4546. * Determines if a container is an ascendant of the current control
  4547. * @param container defines the container to look for
  4548. * @returns true if the container is one of the ascendant of the control
  4549. */
  4550. Control.prototype.isAscendant = function (container) {
  4551. if (!this.parent) {
  4552. return false;
  4553. }
  4554. if (this.parent === container) {
  4555. return true;
  4556. }
  4557. return this.parent.isAscendant(container);
  4558. };
  4559. /**
  4560. * Gets coordinates in local control space
  4561. * @param globalCoordinates defines the coordinates to transform
  4562. * @returns the new coordinates in local space
  4563. */
  4564. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4565. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4566. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4567. return result;
  4568. };
  4569. /**
  4570. * Gets coordinates in local control space
  4571. * @param globalCoordinates defines the coordinates to transform
  4572. * @param result defines the target vector2 where to store the result
  4573. * @returns the current control
  4574. */
  4575. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4576. result.x = globalCoordinates.x - this._currentMeasure.left;
  4577. result.y = globalCoordinates.y - this._currentMeasure.top;
  4578. return this;
  4579. };
  4580. /**
  4581. * Gets coordinates in parent local control space
  4582. * @param globalCoordinates defines the coordinates to transform
  4583. * @returns the new coordinates in parent local space
  4584. */
  4585. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4586. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4587. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4588. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4589. return result;
  4590. };
  4591. /**
  4592. * Move the current control to a vector3 position projected onto the screen.
  4593. * @param position defines the target position
  4594. * @param scene defines the hosting scene
  4595. */
  4596. Control.prototype.moveToVector3 = function (position, scene) {
  4597. if (!this._host || this.parent !== this._host._rootContainer) {
  4598. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4599. return;
  4600. }
  4601. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4602. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4603. var globalViewport = this._host._getGlobalViewport(scene);
  4604. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4605. this._moveToProjectedPosition(projectedPosition);
  4606. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4607. this.notRenderable = true;
  4608. return;
  4609. }
  4610. this.notRenderable = false;
  4611. };
  4612. /**
  4613. * Will store all controls that have this control as ascendant in a given array
  4614. * @param results defines the array where to store the descendants
  4615. * @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
  4616. * @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
  4617. */
  4618. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4619. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4620. // Do nothing by default
  4621. };
  4622. /**
  4623. * Will return all controls that have this control as ascendant
  4624. * @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
  4625. * @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
  4626. * @return all child controls
  4627. */
  4628. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4629. var results = new Array();
  4630. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4631. return results;
  4632. };
  4633. /**
  4634. * Link current control with a target mesh
  4635. * @param mesh defines the mesh to link with
  4636. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4637. */
  4638. Control.prototype.linkWithMesh = function (mesh) {
  4639. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4640. if (mesh) {
  4641. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4642. }
  4643. return;
  4644. }
  4645. var index = this._host._linkedControls.indexOf(this);
  4646. if (index !== -1) {
  4647. this._linkedMesh = mesh;
  4648. if (!mesh) {
  4649. this._host._linkedControls.splice(index, 1);
  4650. }
  4651. return;
  4652. }
  4653. else if (!mesh) {
  4654. return;
  4655. }
  4656. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4657. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4658. this._linkedMesh = mesh;
  4659. this._host._linkedControls.push(this);
  4660. };
  4661. /** @hidden */
  4662. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4663. var oldLeft = this._left.getValue(this._host);
  4664. var oldTop = this._top.getValue(this._host);
  4665. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4666. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4667. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4668. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4669. newLeft = oldLeft;
  4670. }
  4671. if (Math.abs(newTop - oldTop) < 0.5) {
  4672. newTop = oldTop;
  4673. }
  4674. }
  4675. this.left = newLeft + "px";
  4676. this.top = newTop + "px";
  4677. this._left.ignoreAdaptiveScaling = true;
  4678. this._top.ignoreAdaptiveScaling = true;
  4679. this._markAsDirty();
  4680. };
  4681. /** @hidden */
  4682. Control.prototype._offsetLeft = function (offset) {
  4683. this._isDirty = true;
  4684. this._currentMeasure.left += offset;
  4685. };
  4686. /** @hidden */
  4687. Control.prototype._offsetTop = function (offset) {
  4688. this._isDirty = true;
  4689. this._currentMeasure.top += offset;
  4690. };
  4691. /** @hidden */
  4692. Control.prototype._markMatrixAsDirty = function () {
  4693. this._isMatrixDirty = true;
  4694. this._flagDescendantsAsMatrixDirty();
  4695. };
  4696. /** @hidden */
  4697. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4698. // No child
  4699. };
  4700. /** @hidden */
  4701. Control.prototype._intersectsRect = function (rect) {
  4702. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4703. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4704. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4705. return false;
  4706. }
  4707. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4708. return false;
  4709. }
  4710. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4711. return false;
  4712. }
  4713. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4714. return false;
  4715. }
  4716. return true;
  4717. };
  4718. /** @hidden */
  4719. Control.prototype.invalidateRect = function () {
  4720. this._transform();
  4721. if (this.host && this.host.useInvalidateRectOptimization) {
  4722. // Rotate by transform to get the measure transformed to global space
  4723. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4724. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4725. // the previous measure is used to properly clear a control that is scaled down
  4726. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4727. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4728. // Expand rect based on shadows
  4729. var shadowOffsetX = this.shadowOffsetX;
  4730. var shadowOffsetY = this.shadowOffsetY;
  4731. var shadowBlur = this.shadowBlur;
  4732. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4733. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4734. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4735. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4736. 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));
  4737. }
  4738. else {
  4739. 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));
  4740. }
  4741. }
  4742. };
  4743. /** @hidden */
  4744. Control.prototype._markAsDirty = function (force) {
  4745. if (force === void 0) { force = false; }
  4746. if (!this._isVisible && !force) {
  4747. return;
  4748. }
  4749. this._isDirty = true;
  4750. // Redraw only this rectangle
  4751. if (this._host) {
  4752. this._host.markAsDirty();
  4753. }
  4754. };
  4755. /** @hidden */
  4756. Control.prototype._markAllAsDirty = function () {
  4757. this._markAsDirty();
  4758. if (this._font) {
  4759. this._prepareFont();
  4760. }
  4761. };
  4762. /** @hidden */
  4763. Control.prototype._link = function (host) {
  4764. this._host = host;
  4765. if (this._host) {
  4766. this.uniqueId = this._host.getScene().getUniqueId();
  4767. }
  4768. };
  4769. /** @hidden */
  4770. Control.prototype._transform = function (context) {
  4771. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4772. return;
  4773. }
  4774. // postTranslate
  4775. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4776. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4777. if (context) {
  4778. context.translate(offsetX, offsetY);
  4779. // rotate
  4780. context.rotate(this._rotation);
  4781. // scale
  4782. context.scale(this._scaleX, this._scaleY);
  4783. // preTranslate
  4784. context.translate(-offsetX, -offsetY);
  4785. }
  4786. // Need to update matrices?
  4787. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4788. this._cachedOffsetX = offsetX;
  4789. this._cachedOffsetY = offsetY;
  4790. this._isMatrixDirty = false;
  4791. this._flagDescendantsAsMatrixDirty();
  4792. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4793. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._renderHighlight = function (context) {
  4798. if (!this.isHighlighted) {
  4799. return;
  4800. }
  4801. context.save();
  4802. context.strokeStyle = "#4affff";
  4803. context.lineWidth = 2;
  4804. this._renderHighlightSpecific(context);
  4805. context.restore();
  4806. };
  4807. /** @hidden */
  4808. Control.prototype._renderHighlightSpecific = function (context) {
  4809. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4810. };
  4811. /** @hidden */
  4812. Control.prototype._applyStates = function (context) {
  4813. if (this._isFontSizeInPercentage) {
  4814. this._fontSet = true;
  4815. }
  4816. if (this._fontSet) {
  4817. this._prepareFont();
  4818. this._fontSet = false;
  4819. }
  4820. if (this._font) {
  4821. context.font = this._font;
  4822. }
  4823. if (this._color) {
  4824. context.fillStyle = this._color;
  4825. }
  4826. if (Control.AllowAlphaInheritance) {
  4827. context.globalAlpha *= this._alpha;
  4828. }
  4829. else if (this._alphaSet) {
  4830. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4831. }
  4832. };
  4833. /** @hidden */
  4834. Control.prototype._layout = function (parentMeasure, context) {
  4835. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4836. return false;
  4837. }
  4838. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4839. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4840. context.save();
  4841. this._applyStates(context);
  4842. var rebuildCount = 0;
  4843. do {
  4844. this._rebuildLayout = false;
  4845. this._processMeasures(parentMeasure, context);
  4846. rebuildCount++;
  4847. } while (this._rebuildLayout && rebuildCount < 3);
  4848. if (rebuildCount >= 3) {
  4849. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4850. }
  4851. context.restore();
  4852. this.invalidateRect();
  4853. this._evaluateClippingState(parentMeasure);
  4854. }
  4855. this._wasDirty = this._isDirty;
  4856. this._isDirty = false;
  4857. return true;
  4858. };
  4859. /** @hidden */
  4860. Control.prototype._processMeasures = function (parentMeasure, context) {
  4861. this._currentMeasure.copyFrom(parentMeasure);
  4862. // Let children take some pre-measurement actions
  4863. this._preMeasure(parentMeasure, context);
  4864. this._measure();
  4865. this._computeAlignment(parentMeasure, context);
  4866. // Convert to int values
  4867. this._currentMeasure.left = this._currentMeasure.left | 0;
  4868. this._currentMeasure.top = this._currentMeasure.top | 0;
  4869. this._currentMeasure.width = this._currentMeasure.width | 0;
  4870. this._currentMeasure.height = this._currentMeasure.height | 0;
  4871. // Let children add more features
  4872. this._additionalProcessing(parentMeasure, context);
  4873. this._cachedParentMeasure.copyFrom(parentMeasure);
  4874. if (this.onDirtyObservable.hasObservers()) {
  4875. this.onDirtyObservable.notifyObservers(this);
  4876. }
  4877. };
  4878. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4879. if (this.parent && this.parent.clipChildren) {
  4880. // Early clip
  4881. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4882. this._isClipped = true;
  4883. return;
  4884. }
  4885. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4886. this._isClipped = true;
  4887. return;
  4888. }
  4889. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4890. this._isClipped = true;
  4891. return;
  4892. }
  4893. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4894. this._isClipped = true;
  4895. return;
  4896. }
  4897. }
  4898. this._isClipped = false;
  4899. };
  4900. /** @hidden */
  4901. Control.prototype._measure = function () {
  4902. // Width / Height
  4903. if (this._width.isPixel) {
  4904. this._currentMeasure.width = this._width.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.width *= this._width.getValue(this._host);
  4908. }
  4909. if (this._height.isPixel) {
  4910. this._currentMeasure.height = this._height.getValue(this._host);
  4911. }
  4912. else {
  4913. this._currentMeasure.height *= this._height.getValue(this._host);
  4914. }
  4915. };
  4916. /** @hidden */
  4917. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4918. var width = this._currentMeasure.width;
  4919. var height = this._currentMeasure.height;
  4920. var parentWidth = parentMeasure.width;
  4921. var parentHeight = parentMeasure.height;
  4922. // Left / top
  4923. var x = 0;
  4924. var y = 0;
  4925. switch (this.horizontalAlignment) {
  4926. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4927. x = 0;
  4928. break;
  4929. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4930. x = parentWidth - width;
  4931. break;
  4932. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4933. x = (parentWidth - width) / 2;
  4934. break;
  4935. }
  4936. switch (this.verticalAlignment) {
  4937. case Control.VERTICAL_ALIGNMENT_TOP:
  4938. y = 0;
  4939. break;
  4940. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4941. y = parentHeight - height;
  4942. break;
  4943. case Control.VERTICAL_ALIGNMENT_CENTER:
  4944. y = (parentHeight - height) / 2;
  4945. break;
  4946. }
  4947. if (this._paddingLeft.isPixel) {
  4948. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4949. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4950. }
  4951. else {
  4952. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4953. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4954. }
  4955. if (this._paddingRight.isPixel) {
  4956. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4957. }
  4958. else {
  4959. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4960. }
  4961. if (this._paddingTop.isPixel) {
  4962. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4963. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4964. }
  4965. else {
  4966. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4967. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4968. }
  4969. if (this._paddingBottom.isPixel) {
  4970. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4974. }
  4975. if (this._left.isPixel) {
  4976. this._currentMeasure.left += this._left.getValue(this._host);
  4977. }
  4978. else {
  4979. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4980. }
  4981. if (this._top.isPixel) {
  4982. this._currentMeasure.top += this._top.getValue(this._host);
  4983. }
  4984. else {
  4985. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4986. }
  4987. this._currentMeasure.left += x;
  4988. this._currentMeasure.top += y;
  4989. };
  4990. /** @hidden */
  4991. Control.prototype._preMeasure = function (parentMeasure, context) {
  4992. // Do nothing
  4993. };
  4994. /** @hidden */
  4995. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4996. // Do nothing
  4997. };
  4998. /** @hidden */
  4999. Control.prototype._clipForChildren = function (context) {
  5000. // DO nothing
  5001. };
  5002. Control.prototype._clip = function (context, invalidatedRectangle) {
  5003. context.beginPath();
  5004. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5005. if (invalidatedRectangle) {
  5006. // Rotate the invalidated rect into the control's space
  5007. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5008. // Get the intersection of the rect in context space and the current context
  5009. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5010. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5011. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5012. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5013. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5014. Control._ClipMeasure.copyFrom(intersection);
  5015. }
  5016. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5017. var shadowOffsetX = this.shadowOffsetX;
  5018. var shadowOffsetY = this.shadowOffsetY;
  5019. var shadowBlur = this.shadowBlur;
  5020. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5021. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5022. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5023. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5024. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5025. }
  5026. else {
  5027. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5028. }
  5029. context.clip();
  5030. };
  5031. /** @hidden */
  5032. Control.prototype._render = function (context, invalidatedRectangle) {
  5033. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5034. this._isDirty = false;
  5035. return false;
  5036. }
  5037. context.save();
  5038. this._applyStates(context);
  5039. // Transform
  5040. this._transform(context);
  5041. // Clip
  5042. if (this.clipContent) {
  5043. this._clip(context, invalidatedRectangle);
  5044. }
  5045. if (this.onBeforeDrawObservable.hasObservers()) {
  5046. this.onBeforeDrawObservable.notifyObservers(this);
  5047. }
  5048. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5049. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5050. }
  5051. else {
  5052. this._draw(context, invalidatedRectangle);
  5053. }
  5054. if (this.useBitmapCache && this._wasDirty) {
  5055. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5056. }
  5057. this._renderHighlight(context);
  5058. if (this.onAfterDrawObservable.hasObservers()) {
  5059. this.onAfterDrawObservable.notifyObservers(this);
  5060. }
  5061. context.restore();
  5062. return true;
  5063. };
  5064. /** @hidden */
  5065. Control.prototype._draw = function (context, invalidatedRectangle) {
  5066. // Do nothing
  5067. };
  5068. /**
  5069. * Tests if a given coordinates belong to the current control
  5070. * @param x defines x coordinate to test
  5071. * @param y defines y coordinate to test
  5072. * @returns true if the coordinates are inside the control
  5073. */
  5074. Control.prototype.contains = function (x, y) {
  5075. // Invert transform
  5076. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5077. x = this._transformedPosition.x;
  5078. y = this._transformedPosition.y;
  5079. // Check
  5080. if (x < this._currentMeasure.left) {
  5081. return false;
  5082. }
  5083. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5084. return false;
  5085. }
  5086. if (y < this._currentMeasure.top) {
  5087. return false;
  5088. }
  5089. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5090. return false;
  5091. }
  5092. if (this.isPointerBlocker) {
  5093. this._host._shouldBlockPointer = true;
  5094. }
  5095. return true;
  5096. };
  5097. /** @hidden */
  5098. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5099. if (!this._isEnabled) {
  5100. return false;
  5101. }
  5102. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5103. return false;
  5104. }
  5105. if (!this.contains(x, y)) {
  5106. return false;
  5107. }
  5108. this._processObservables(type, x, y, pointerId, buttonIndex);
  5109. return true;
  5110. };
  5111. /** @hidden */
  5112. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5113. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5114. if (canNotify && this.parent != null) {
  5115. this.parent._onPointerMove(target, coordinates, pointerId);
  5116. }
  5117. };
  5118. /** @hidden */
  5119. Control.prototype._onPointerEnter = function (target) {
  5120. if (!this._isEnabled) {
  5121. return false;
  5122. }
  5123. if (this._enterCount > 0) {
  5124. return false;
  5125. }
  5126. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5127. this._enterCount = 0;
  5128. }
  5129. this._enterCount++;
  5130. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5131. if (canNotify && this.parent != null) {
  5132. this.parent._onPointerEnter(target);
  5133. }
  5134. return true;
  5135. };
  5136. /** @hidden */
  5137. Control.prototype._onPointerOut = function (target, force) {
  5138. if (force === void 0) { force = false; }
  5139. if (!force && (!this._isEnabled || target === this)) {
  5140. return;
  5141. }
  5142. this._enterCount = 0;
  5143. var canNotify = true;
  5144. if (!target.isAscendant(this)) {
  5145. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5146. }
  5147. if (canNotify && this.parent != null) {
  5148. this.parent._onPointerOut(target, force);
  5149. }
  5150. };
  5151. /** @hidden */
  5152. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5153. // Prevent pointerout to lose control context.
  5154. // Event redundancy is checked inside the function.
  5155. this._onPointerEnter(this);
  5156. if (this._downCount !== 0) {
  5157. return false;
  5158. }
  5159. this._downCount++;
  5160. this._downPointerIds[pointerId] = true;
  5161. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5162. if (canNotify && this.parent != null) {
  5163. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5164. }
  5165. return true;
  5166. };
  5167. /** @hidden */
  5168. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5169. if (!this._isEnabled) {
  5170. return;
  5171. }
  5172. this._downCount = 0;
  5173. delete this._downPointerIds[pointerId];
  5174. var canNotifyClick = notifyClick;
  5175. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5176. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5177. }
  5178. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5179. if (canNotify && this.parent != null) {
  5180. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5181. }
  5182. };
  5183. /** @hidden */
  5184. Control.prototype._forcePointerUp = function (pointerId) {
  5185. if (pointerId === void 0) { pointerId = null; }
  5186. if (pointerId !== null) {
  5187. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5188. }
  5189. else {
  5190. for (var key in this._downPointerIds) {
  5191. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5192. }
  5193. }
  5194. };
  5195. /** @hidden */
  5196. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5197. if (!this._isEnabled) {
  5198. return false;
  5199. }
  5200. this._dummyVector2.copyFromFloats(x, y);
  5201. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5202. this._onPointerMove(this, this._dummyVector2, pointerId);
  5203. var previousControlOver = this._host._lastControlOver[pointerId];
  5204. if (previousControlOver && previousControlOver !== this) {
  5205. previousControlOver._onPointerOut(this);
  5206. }
  5207. if (previousControlOver !== this) {
  5208. this._onPointerEnter(this);
  5209. }
  5210. this._host._lastControlOver[pointerId] = this;
  5211. return true;
  5212. }
  5213. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5214. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5215. this._host._registerLastControlDown(this, pointerId);
  5216. this._host._lastPickedControl = this;
  5217. return true;
  5218. }
  5219. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5220. if (this._host._lastControlDown[pointerId]) {
  5221. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5222. }
  5223. delete this._host._lastControlDown[pointerId];
  5224. return true;
  5225. }
  5226. return false;
  5227. };
  5228. Control.prototype._prepareFont = function () {
  5229. if (!this._font && !this._fontSet) {
  5230. return;
  5231. }
  5232. if (this._style) {
  5233. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5234. }
  5235. else {
  5236. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5237. }
  5238. this._fontOffset = Control._GetFontOffset(this._font);
  5239. };
  5240. /** Releases associated resources */
  5241. Control.prototype.dispose = function () {
  5242. this.onDirtyObservable.clear();
  5243. this.onBeforeDrawObservable.clear();
  5244. this.onAfterDrawObservable.clear();
  5245. this.onPointerDownObservable.clear();
  5246. this.onPointerEnterObservable.clear();
  5247. this.onPointerMoveObservable.clear();
  5248. this.onPointerOutObservable.clear();
  5249. this.onPointerUpObservable.clear();
  5250. this.onPointerClickObservable.clear();
  5251. if (this._styleObserver && this._style) {
  5252. this._style.onChangedObservable.remove(this._styleObserver);
  5253. this._styleObserver = null;
  5254. }
  5255. if (this.parent) {
  5256. this.parent.removeControl(this);
  5257. this.parent = null;
  5258. }
  5259. if (this._host) {
  5260. var index = this._host._linkedControls.indexOf(this);
  5261. if (index > -1) {
  5262. this.linkWithMesh(null);
  5263. }
  5264. }
  5265. };
  5266. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5267. /** HORIZONTAL_ALIGNMENT_LEFT */
  5268. get: function () {
  5269. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5270. },
  5271. enumerable: true,
  5272. configurable: true
  5273. });
  5274. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5275. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5276. get: function () {
  5277. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5278. },
  5279. enumerable: true,
  5280. configurable: true
  5281. });
  5282. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5283. /** HORIZONTAL_ALIGNMENT_CENTER */
  5284. get: function () {
  5285. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5286. },
  5287. enumerable: true,
  5288. configurable: true
  5289. });
  5290. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5291. /** VERTICAL_ALIGNMENT_TOP */
  5292. get: function () {
  5293. return Control._VERTICAL_ALIGNMENT_TOP;
  5294. },
  5295. enumerable: true,
  5296. configurable: true
  5297. });
  5298. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5299. /** VERTICAL_ALIGNMENT_BOTTOM */
  5300. get: function () {
  5301. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5302. },
  5303. enumerable: true,
  5304. configurable: true
  5305. });
  5306. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5307. /** VERTICAL_ALIGNMENT_CENTER */
  5308. get: function () {
  5309. return Control._VERTICAL_ALIGNMENT_CENTER;
  5310. },
  5311. enumerable: true,
  5312. configurable: true
  5313. });
  5314. /** @hidden */
  5315. Control._GetFontOffset = function (font) {
  5316. if (Control._FontHeightSizes[font]) {
  5317. return Control._FontHeightSizes[font];
  5318. }
  5319. var text = document.createElement("span");
  5320. text.innerHTML = "Hg";
  5321. text.style.font = font;
  5322. var block = document.createElement("div");
  5323. block.style.display = "inline-block";
  5324. block.style.width = "1px";
  5325. block.style.height = "0px";
  5326. block.style.verticalAlign = "bottom";
  5327. var div = document.createElement("div");
  5328. div.appendChild(text);
  5329. div.appendChild(block);
  5330. document.body.appendChild(div);
  5331. var fontAscent = 0;
  5332. var fontHeight = 0;
  5333. try {
  5334. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5335. block.style.verticalAlign = "baseline";
  5336. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5337. }
  5338. finally {
  5339. document.body.removeChild(div);
  5340. }
  5341. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5342. Control._FontHeightSizes[font] = result;
  5343. return result;
  5344. };
  5345. /** @hidden */
  5346. Control.drawEllipse = function (x, y, width, height, context) {
  5347. context.translate(x, y);
  5348. context.scale(width, height);
  5349. context.beginPath();
  5350. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5351. context.closePath();
  5352. context.scale(1 / width, 1 / height);
  5353. context.translate(-x, -y);
  5354. };
  5355. /**
  5356. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5357. */
  5358. Control.AllowAlphaInheritance = false;
  5359. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5360. // Statics
  5361. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5362. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5363. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5364. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5365. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5366. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5367. Control._FontHeightSizes = {};
  5368. /**
  5369. * Creates a stack panel that can be used to render headers
  5370. * @param control defines the control to associate with the header
  5371. * @param text defines the text of the header
  5372. * @param size defines the size of the header
  5373. * @param options defines options used to configure the header
  5374. * @returns a new StackPanel
  5375. * @ignore
  5376. * @hidden
  5377. */
  5378. Control.AddHeader = function () { };
  5379. return Control;
  5380. }());
  5381. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5382. /***/ }),
  5383. /***/ "./2D/controls/displayGrid.ts":
  5384. /*!************************************!*\
  5385. !*** ./2D/controls/displayGrid.ts ***!
  5386. \************************************/
  5387. /*! exports provided: DisplayGrid */
  5388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5389. "use strict";
  5390. __webpack_require__.r(__webpack_exports__);
  5391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5392. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5393. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5394. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5395. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5396. /** Class used to render a grid */
  5397. var DisplayGrid = /** @class */ (function (_super) {
  5398. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5399. /**
  5400. * Creates a new GridDisplayRectangle
  5401. * @param name defines the control name
  5402. */
  5403. function DisplayGrid(name) {
  5404. var _this = _super.call(this, name) || this;
  5405. _this.name = name;
  5406. _this._cellWidth = 20;
  5407. _this._cellHeight = 20;
  5408. _this._minorLineTickness = 1;
  5409. _this._minorLineColor = "DarkGray";
  5410. _this._majorLineTickness = 2;
  5411. _this._majorLineColor = "White";
  5412. _this._majorLineFrequency = 5;
  5413. _this._background = "Black";
  5414. _this._displayMajorLines = true;
  5415. _this._displayMinorLines = true;
  5416. return _this;
  5417. }
  5418. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5419. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5420. get: function () {
  5421. return this._displayMinorLines;
  5422. },
  5423. set: function (value) {
  5424. if (this._displayMinorLines === value) {
  5425. return;
  5426. }
  5427. this._displayMinorLines = value;
  5428. this._markAsDirty();
  5429. },
  5430. enumerable: true,
  5431. configurable: true
  5432. });
  5433. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5434. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5435. get: function () {
  5436. return this._displayMajorLines;
  5437. },
  5438. set: function (value) {
  5439. if (this._displayMajorLines === value) {
  5440. return;
  5441. }
  5442. this._displayMajorLines = value;
  5443. this._markAsDirty();
  5444. },
  5445. enumerable: true,
  5446. configurable: true
  5447. });
  5448. Object.defineProperty(DisplayGrid.prototype, "background", {
  5449. /** Gets or sets background color (Black by default) */
  5450. get: function () {
  5451. return this._background;
  5452. },
  5453. set: function (value) {
  5454. if (this._background === value) {
  5455. return;
  5456. }
  5457. this._background = value;
  5458. this._markAsDirty();
  5459. },
  5460. enumerable: true,
  5461. configurable: true
  5462. });
  5463. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5464. /** Gets or sets the width of each cell (20 by default) */
  5465. get: function () {
  5466. return this._cellWidth;
  5467. },
  5468. set: function (value) {
  5469. this._cellWidth = value;
  5470. this._markAsDirty();
  5471. },
  5472. enumerable: true,
  5473. configurable: true
  5474. });
  5475. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5476. /** Gets or sets the height of each cell (20 by default) */
  5477. get: function () {
  5478. return this._cellHeight;
  5479. },
  5480. set: function (value) {
  5481. this._cellHeight = value;
  5482. this._markAsDirty();
  5483. },
  5484. enumerable: true,
  5485. configurable: true
  5486. });
  5487. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5488. /** Gets or sets the tickness of minor lines (1 by default) */
  5489. get: function () {
  5490. return this._minorLineTickness;
  5491. },
  5492. set: function (value) {
  5493. this._minorLineTickness = value;
  5494. this._markAsDirty();
  5495. },
  5496. enumerable: true,
  5497. configurable: true
  5498. });
  5499. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5500. /** Gets or sets the color of minor lines (DarkGray by default) */
  5501. get: function () {
  5502. return this._minorLineColor;
  5503. },
  5504. set: function (value) {
  5505. this._minorLineColor = value;
  5506. this._markAsDirty();
  5507. },
  5508. enumerable: true,
  5509. configurable: true
  5510. });
  5511. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5512. /** Gets or sets the tickness of major lines (2 by default) */
  5513. get: function () {
  5514. return this._majorLineTickness;
  5515. },
  5516. set: function (value) {
  5517. this._majorLineTickness = value;
  5518. this._markAsDirty();
  5519. },
  5520. enumerable: true,
  5521. configurable: true
  5522. });
  5523. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5524. /** Gets or sets the color of major lines (White by default) */
  5525. get: function () {
  5526. return this._majorLineColor;
  5527. },
  5528. set: function (value) {
  5529. this._majorLineColor = value;
  5530. this._markAsDirty();
  5531. },
  5532. enumerable: true,
  5533. configurable: true
  5534. });
  5535. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5536. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5537. get: function () {
  5538. return this._majorLineFrequency;
  5539. },
  5540. set: function (value) {
  5541. this._majorLineFrequency = value;
  5542. this._markAsDirty();
  5543. },
  5544. enumerable: true,
  5545. configurable: true
  5546. });
  5547. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5548. context.save();
  5549. this._applyStates(context);
  5550. if (this._isEnabled) {
  5551. if (this._background) {
  5552. context.fillStyle = this._background;
  5553. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5554. }
  5555. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5556. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5557. // Minor lines
  5558. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5559. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5560. if (this._displayMinorLines) {
  5561. context.strokeStyle = this._minorLineColor;
  5562. context.lineWidth = this._minorLineTickness;
  5563. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5564. var cellX = left + x * this.cellWidth;
  5565. context.beginPath();
  5566. context.moveTo(cellX, this._currentMeasure.top);
  5567. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5568. context.stroke();
  5569. }
  5570. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5571. var cellY = top_1 + y * this.cellHeight;
  5572. context.beginPath();
  5573. context.moveTo(this._currentMeasure.left, cellY);
  5574. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5575. context.stroke();
  5576. }
  5577. }
  5578. // Major lines
  5579. if (this._displayMajorLines) {
  5580. context.strokeStyle = this._majorLineColor;
  5581. context.lineWidth = this._majorLineTickness;
  5582. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5583. var cellX = left + x * this.cellWidth;
  5584. context.beginPath();
  5585. context.moveTo(cellX, this._currentMeasure.top);
  5586. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5587. context.stroke();
  5588. }
  5589. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5590. var cellY = top_1 + y * this.cellHeight;
  5591. context.moveTo(this._currentMeasure.left, cellY);
  5592. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5593. context.closePath();
  5594. context.stroke();
  5595. }
  5596. }
  5597. }
  5598. context.restore();
  5599. };
  5600. DisplayGrid.prototype._getTypeName = function () {
  5601. return "DisplayGrid";
  5602. };
  5603. return DisplayGrid;
  5604. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5605. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5606. /***/ }),
  5607. /***/ "./2D/controls/ellipse.ts":
  5608. /*!********************************!*\
  5609. !*** ./2D/controls/ellipse.ts ***!
  5610. \********************************/
  5611. /*! exports provided: Ellipse */
  5612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5613. "use strict";
  5614. __webpack_require__.r(__webpack_exports__);
  5615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5617. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5618. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5619. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5620. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5621. /** Class used to create 2D ellipse containers */
  5622. var Ellipse = /** @class */ (function (_super) {
  5623. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5624. /**
  5625. * Creates a new Ellipse
  5626. * @param name defines the control name
  5627. */
  5628. function Ellipse(name) {
  5629. var _this = _super.call(this, name) || this;
  5630. _this.name = name;
  5631. _this._thickness = 1;
  5632. return _this;
  5633. }
  5634. Object.defineProperty(Ellipse.prototype, "thickness", {
  5635. /** Gets or sets border thickness */
  5636. get: function () {
  5637. return this._thickness;
  5638. },
  5639. set: function (value) {
  5640. if (this._thickness === value) {
  5641. return;
  5642. }
  5643. this._thickness = value;
  5644. this._markAsDirty();
  5645. },
  5646. enumerable: true,
  5647. configurable: true
  5648. });
  5649. Ellipse.prototype._getTypeName = function () {
  5650. return "Ellipse";
  5651. };
  5652. Ellipse.prototype._localDraw = function (context) {
  5653. context.save();
  5654. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5655. context.shadowColor = this.shadowColor;
  5656. context.shadowBlur = this.shadowBlur;
  5657. context.shadowOffsetX = this.shadowOffsetX;
  5658. context.shadowOffsetY = this.shadowOffsetY;
  5659. }
  5660. _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);
  5661. if (this._background) {
  5662. context.fillStyle = this._background;
  5663. context.fill();
  5664. }
  5665. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5666. context.shadowBlur = 0;
  5667. context.shadowOffsetX = 0;
  5668. context.shadowOffsetY = 0;
  5669. }
  5670. if (this._thickness) {
  5671. if (this.color) {
  5672. context.strokeStyle = this.color;
  5673. }
  5674. context.lineWidth = this._thickness;
  5675. context.stroke();
  5676. }
  5677. context.restore();
  5678. };
  5679. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5680. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5681. this._measureForChildren.width -= 2 * this._thickness;
  5682. this._measureForChildren.height -= 2 * this._thickness;
  5683. this._measureForChildren.left += this._thickness;
  5684. this._measureForChildren.top += this._thickness;
  5685. };
  5686. Ellipse.prototype._clipForChildren = function (context) {
  5687. _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);
  5688. context.clip();
  5689. };
  5690. return Ellipse;
  5691. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5692. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5693. /***/ }),
  5694. /***/ "./2D/controls/grid.ts":
  5695. /*!*****************************!*\
  5696. !*** ./2D/controls/grid.ts ***!
  5697. \*****************************/
  5698. /*! exports provided: Grid */
  5699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5700. "use strict";
  5701. __webpack_require__.r(__webpack_exports__);
  5702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5703. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5704. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5705. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5706. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5707. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5708. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5709. /**
  5710. * Class used to create a 2D grid container
  5711. */
  5712. var Grid = /** @class */ (function (_super) {
  5713. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5714. /**
  5715. * Creates a new Grid
  5716. * @param name defines control name
  5717. */
  5718. function Grid(name) {
  5719. var _this = _super.call(this, name) || this;
  5720. _this.name = name;
  5721. _this._rowDefinitions = new Array();
  5722. _this._columnDefinitions = new Array();
  5723. _this._cells = {};
  5724. _this._childControls = new Array();
  5725. return _this;
  5726. }
  5727. Object.defineProperty(Grid.prototype, "columnCount", {
  5728. /**
  5729. * Gets the number of columns
  5730. */
  5731. get: function () {
  5732. return this._columnDefinitions.length;
  5733. },
  5734. enumerable: true,
  5735. configurable: true
  5736. });
  5737. Object.defineProperty(Grid.prototype, "rowCount", {
  5738. /**
  5739. * Gets the number of rows
  5740. */
  5741. get: function () {
  5742. return this._rowDefinitions.length;
  5743. },
  5744. enumerable: true,
  5745. configurable: true
  5746. });
  5747. Object.defineProperty(Grid.prototype, "children", {
  5748. /** Gets the list of children */
  5749. get: function () {
  5750. return this._childControls;
  5751. },
  5752. enumerable: true,
  5753. configurable: true
  5754. });
  5755. Object.defineProperty(Grid.prototype, "cells", {
  5756. /** Gets the list of cells (e.g. the containers) */
  5757. get: function () {
  5758. return this._cells;
  5759. },
  5760. enumerable: true,
  5761. configurable: true
  5762. });
  5763. /**
  5764. * Gets the definition of a specific row
  5765. * @param index defines the index of the row
  5766. * @returns the row definition
  5767. */
  5768. Grid.prototype.getRowDefinition = function (index) {
  5769. if (index < 0 || index >= this._rowDefinitions.length) {
  5770. return null;
  5771. }
  5772. return this._rowDefinitions[index];
  5773. };
  5774. /**
  5775. * Gets the definition of a specific column
  5776. * @param index defines the index of the column
  5777. * @returns the column definition
  5778. */
  5779. Grid.prototype.getColumnDefinition = function (index) {
  5780. if (index < 0 || index >= this._columnDefinitions.length) {
  5781. return null;
  5782. }
  5783. return this._columnDefinitions[index];
  5784. };
  5785. /**
  5786. * Adds a new row to the grid
  5787. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5788. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5789. * @returns the current grid
  5790. */
  5791. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5792. if (isPixel === void 0) { isPixel = false; }
  5793. 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));
  5794. this._markAsDirty();
  5795. return this;
  5796. };
  5797. /**
  5798. * Adds a new column to the grid
  5799. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5800. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5801. * @returns the current grid
  5802. */
  5803. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5804. if (isPixel === void 0) { isPixel = false; }
  5805. 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));
  5806. this._markAsDirty();
  5807. return this;
  5808. };
  5809. /**
  5810. * Update a row definition
  5811. * @param index defines the index of the row to update
  5812. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5813. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5814. * @returns the current grid
  5815. */
  5816. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5817. if (isPixel === void 0) { isPixel = false; }
  5818. if (index < 0 || index >= this._rowDefinitions.length) {
  5819. return this;
  5820. }
  5821. var current = this._rowDefinitions[index];
  5822. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5823. return this;
  5824. }
  5825. 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);
  5826. this._markAsDirty();
  5827. return this;
  5828. };
  5829. /**
  5830. * Update a column definition
  5831. * @param index defines the index of the column to update
  5832. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5833. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5834. * @returns the current grid
  5835. */
  5836. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5837. if (isPixel === void 0) { isPixel = false; }
  5838. if (index < 0 || index >= this._columnDefinitions.length) {
  5839. return this;
  5840. }
  5841. var current = this._columnDefinitions[index];
  5842. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5843. return this;
  5844. }
  5845. 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);
  5846. this._markAsDirty();
  5847. return this;
  5848. };
  5849. /**
  5850. * Gets the list of children stored in a specific cell
  5851. * @param row defines the row to check
  5852. * @param column defines the column to check
  5853. * @returns the list of controls
  5854. */
  5855. Grid.prototype.getChildrenAt = function (row, column) {
  5856. var cell = this._cells[row + ":" + column];
  5857. if (!cell) {
  5858. return null;
  5859. }
  5860. return cell.children;
  5861. };
  5862. /**
  5863. * Gets a string representing the child cell info (row x column)
  5864. * @param child defines the control to get info from
  5865. * @returns a string containing the child cell info (row x column)
  5866. */
  5867. Grid.prototype.getChildCellInfo = function (child) {
  5868. return child._tag;
  5869. };
  5870. Grid.prototype._removeCell = function (cell, key) {
  5871. if (!cell) {
  5872. return;
  5873. }
  5874. _super.prototype.removeControl.call(this, cell);
  5875. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5876. var control = _a[_i];
  5877. var childIndex = this._childControls.indexOf(control);
  5878. if (childIndex !== -1) {
  5879. this._childControls.splice(childIndex, 1);
  5880. }
  5881. }
  5882. delete this._cells[key];
  5883. };
  5884. Grid.prototype._offsetCell = function (previousKey, key) {
  5885. if (!this._cells[key]) {
  5886. return;
  5887. }
  5888. this._cells[previousKey] = this._cells[key];
  5889. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5890. var control = _a[_i];
  5891. control._tag = previousKey;
  5892. }
  5893. delete this._cells[key];
  5894. };
  5895. /**
  5896. * Remove a column definition at specified index
  5897. * @param index defines the index of the column to remove
  5898. * @returns the current grid
  5899. */
  5900. Grid.prototype.removeColumnDefinition = function (index) {
  5901. if (index < 0 || index >= this._columnDefinitions.length) {
  5902. return this;
  5903. }
  5904. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5905. var key = x + ":" + index;
  5906. var cell = this._cells[key];
  5907. this._removeCell(cell, key);
  5908. }
  5909. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5910. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5911. var previousKey = x + ":" + (y - 1);
  5912. var key = x + ":" + y;
  5913. this._offsetCell(previousKey, key);
  5914. }
  5915. }
  5916. this._columnDefinitions.splice(index, 1);
  5917. this._markAsDirty();
  5918. return this;
  5919. };
  5920. /**
  5921. * Remove a row definition at specified index
  5922. * @param index defines the index of the row to remove
  5923. * @returns the current grid
  5924. */
  5925. Grid.prototype.removeRowDefinition = function (index) {
  5926. if (index < 0 || index >= this._rowDefinitions.length) {
  5927. return this;
  5928. }
  5929. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5930. var key = index + ":" + y;
  5931. var cell = this._cells[key];
  5932. this._removeCell(cell, key);
  5933. }
  5934. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5935. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5936. var previousKey = x - 1 + ":" + y;
  5937. var key = x + ":" + y;
  5938. this._offsetCell(previousKey, key);
  5939. }
  5940. }
  5941. this._rowDefinitions.splice(index, 1);
  5942. this._markAsDirty();
  5943. return this;
  5944. };
  5945. /**
  5946. * Adds a new control to the current grid
  5947. * @param control defines the control to add
  5948. * @param row defines the row where to add the control (0 by default)
  5949. * @param column defines the column where to add the control (0 by default)
  5950. * @returns the current grid
  5951. */
  5952. Grid.prototype.addControl = function (control, row, column) {
  5953. if (row === void 0) { row = 0; }
  5954. if (column === void 0) { column = 0; }
  5955. if (this._rowDefinitions.length === 0) {
  5956. // Add default row definition
  5957. this.addRowDefinition(1, false);
  5958. }
  5959. if (this._columnDefinitions.length === 0) {
  5960. // Add default column definition
  5961. this.addColumnDefinition(1, false);
  5962. }
  5963. if (this._childControls.indexOf(control) !== -1) {
  5964. 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");
  5965. return this;
  5966. }
  5967. var x = Math.min(row, this._rowDefinitions.length - 1);
  5968. var y = Math.min(column, this._columnDefinitions.length - 1);
  5969. var key = x + ":" + y;
  5970. var goodContainer = this._cells[key];
  5971. if (!goodContainer) {
  5972. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5973. this._cells[key] = goodContainer;
  5974. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5975. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5976. _super.prototype.addControl.call(this, goodContainer);
  5977. }
  5978. goodContainer.addControl(control);
  5979. this._childControls.push(control);
  5980. control._tag = key;
  5981. control.parent = this;
  5982. this._markAsDirty();
  5983. return this;
  5984. };
  5985. /**
  5986. * Removes a control from the current container
  5987. * @param control defines the control to remove
  5988. * @returns the current container
  5989. */
  5990. Grid.prototype.removeControl = function (control) {
  5991. var index = this._childControls.indexOf(control);
  5992. if (index !== -1) {
  5993. this._childControls.splice(index, 1);
  5994. }
  5995. var cell = this._cells[control._tag];
  5996. if (cell) {
  5997. cell.removeControl(control);
  5998. control._tag = null;
  5999. }
  6000. this._markAsDirty();
  6001. return this;
  6002. };
  6003. Grid.prototype._getTypeName = function () {
  6004. return "Grid";
  6005. };
  6006. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6007. var widths = [];
  6008. var heights = [];
  6009. var lefts = [];
  6010. var tops = [];
  6011. var availableWidth = this._currentMeasure.width;
  6012. var globalWidthPercentage = 0;
  6013. var availableHeight = this._currentMeasure.height;
  6014. var globalHeightPercentage = 0;
  6015. // Heights
  6016. var index = 0;
  6017. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6018. var value = _a[_i];
  6019. if (value.isPixel) {
  6020. var height = value.getValue(this._host);
  6021. availableHeight -= height;
  6022. heights[index] = height;
  6023. }
  6024. else {
  6025. globalHeightPercentage += value.internalValue;
  6026. }
  6027. index++;
  6028. }
  6029. var top = 0;
  6030. index = 0;
  6031. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6032. var value = _c[_b];
  6033. tops.push(top);
  6034. if (!value.isPixel) {
  6035. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6036. top += height;
  6037. heights[index] = height;
  6038. }
  6039. else {
  6040. top += value.getValue(this._host);
  6041. }
  6042. index++;
  6043. }
  6044. // Widths
  6045. index = 0;
  6046. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6047. var value = _e[_d];
  6048. if (value.isPixel) {
  6049. var width = value.getValue(this._host);
  6050. availableWidth -= width;
  6051. widths[index] = width;
  6052. }
  6053. else {
  6054. globalWidthPercentage += value.internalValue;
  6055. }
  6056. index++;
  6057. }
  6058. var left = 0;
  6059. index = 0;
  6060. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6061. var value = _g[_f];
  6062. lefts.push(left);
  6063. if (!value.isPixel) {
  6064. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6065. left += width;
  6066. widths[index] = width;
  6067. }
  6068. else {
  6069. left += value.getValue(this._host);
  6070. }
  6071. index++;
  6072. }
  6073. definitionCallback(lefts, tops, widths, heights);
  6074. };
  6075. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6076. var _this = this;
  6077. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6078. // Setting child sizes
  6079. for (var key in _this._cells) {
  6080. if (!_this._cells.hasOwnProperty(key)) {
  6081. continue;
  6082. }
  6083. var split = key.split(":");
  6084. var x = parseInt(split[0]);
  6085. var y = parseInt(split[1]);
  6086. var cell = _this._cells[key];
  6087. cell.left = lefts[y] + "px";
  6088. cell.top = tops[x] + "px";
  6089. cell.width = widths[y] + "px";
  6090. cell.height = heights[x] + "px";
  6091. cell._left.ignoreAdaptiveScaling = true;
  6092. cell._top.ignoreAdaptiveScaling = true;
  6093. cell._width.ignoreAdaptiveScaling = true;
  6094. cell._height.ignoreAdaptiveScaling = true;
  6095. }
  6096. });
  6097. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6098. };
  6099. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6100. for (var key in this._cells) {
  6101. if (!this._cells.hasOwnProperty(key)) {
  6102. continue;
  6103. }
  6104. var child = this._cells[key];
  6105. child._markMatrixAsDirty();
  6106. }
  6107. };
  6108. Grid.prototype._renderHighlightSpecific = function (context) {
  6109. var _this = this;
  6110. _super.prototype._renderHighlightSpecific.call(this, context);
  6111. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6112. // Columns
  6113. for (var index = 0; index < lefts.length; index++) {
  6114. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6115. context.beginPath();
  6116. context.moveTo(left, _this._currentMeasure.top);
  6117. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6118. context.stroke();
  6119. }
  6120. // Rows
  6121. for (var index = 0; index < tops.length; index++) {
  6122. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6123. context.beginPath();
  6124. context.moveTo(_this._currentMeasure.left, top_1);
  6125. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6126. context.stroke();
  6127. }
  6128. });
  6129. context.restore();
  6130. };
  6131. /** Releases associated resources */
  6132. Grid.prototype.dispose = function () {
  6133. _super.prototype.dispose.call(this);
  6134. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6135. var control = _a[_i];
  6136. control.dispose();
  6137. }
  6138. this._childControls = [];
  6139. };
  6140. return Grid;
  6141. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6142. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6143. /***/ }),
  6144. /***/ "./2D/controls/image.ts":
  6145. /*!******************************!*\
  6146. !*** ./2D/controls/image.ts ***!
  6147. \******************************/
  6148. /*! exports provided: Image */
  6149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6150. "use strict";
  6151. __webpack_require__.r(__webpack_exports__);
  6152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6153. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6154. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6156. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6157. /**
  6158. * Class used to create 2D images
  6159. */
  6160. var Image = /** @class */ (function (_super) {
  6161. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6162. /**
  6163. * Creates a new Image
  6164. * @param name defines the control name
  6165. * @param url defines the image url
  6166. */
  6167. function Image(name, url) {
  6168. if (url === void 0) { url = null; }
  6169. var _this = _super.call(this, name) || this;
  6170. _this.name = name;
  6171. _this._workingCanvas = null;
  6172. _this._loaded = false;
  6173. _this._stretch = Image.STRETCH_FILL;
  6174. _this._autoScale = false;
  6175. _this._sourceLeft = 0;
  6176. _this._sourceTop = 0;
  6177. _this._sourceWidth = 0;
  6178. _this._sourceHeight = 0;
  6179. _this._cellWidth = 0;
  6180. _this._cellHeight = 0;
  6181. _this._cellId = -1;
  6182. _this._populateNinePatchSlicesFromImage = false;
  6183. /**
  6184. * Observable notified when the content is loaded
  6185. */
  6186. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6187. /**
  6188. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6189. */
  6190. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6191. _this.source = url;
  6192. return _this;
  6193. }
  6194. Object.defineProperty(Image.prototype, "isLoaded", {
  6195. /**
  6196. * Gets a boolean indicating that the content is loaded
  6197. */
  6198. get: function () {
  6199. return this._loaded;
  6200. },
  6201. enumerable: true,
  6202. configurable: true
  6203. });
  6204. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6205. /**
  6206. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6207. */
  6208. get: function () {
  6209. return this._populateNinePatchSlicesFromImage;
  6210. },
  6211. set: function (value) {
  6212. if (this._populateNinePatchSlicesFromImage === value) {
  6213. return;
  6214. }
  6215. this._populateNinePatchSlicesFromImage = value;
  6216. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6217. this._extractNinePatchSliceDataFromImage();
  6218. }
  6219. },
  6220. enumerable: true,
  6221. configurable: true
  6222. });
  6223. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6224. /**
  6225. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6226. * Beware using this as this will comsume more memory as the image has to be stored twice
  6227. */
  6228. get: function () {
  6229. return this._detectPointerOnOpaqueOnly;
  6230. },
  6231. set: function (value) {
  6232. if (this._detectPointerOnOpaqueOnly === value) {
  6233. return;
  6234. }
  6235. this._detectPointerOnOpaqueOnly = value;
  6236. },
  6237. enumerable: true,
  6238. configurable: true
  6239. });
  6240. Object.defineProperty(Image.prototype, "sliceLeft", {
  6241. /**
  6242. * Gets or sets the left value for slicing (9-patch)
  6243. */
  6244. get: function () {
  6245. return this._sliceLeft;
  6246. },
  6247. set: function (value) {
  6248. if (this._sliceLeft === value) {
  6249. return;
  6250. }
  6251. this._sliceLeft = value;
  6252. this._markAsDirty();
  6253. },
  6254. enumerable: true,
  6255. configurable: true
  6256. });
  6257. Object.defineProperty(Image.prototype, "sliceRight", {
  6258. /**
  6259. * Gets or sets the right value for slicing (9-patch)
  6260. */
  6261. get: function () {
  6262. return this._sliceRight;
  6263. },
  6264. set: function (value) {
  6265. if (this._sliceRight === value) {
  6266. return;
  6267. }
  6268. this._sliceRight = value;
  6269. this._markAsDirty();
  6270. },
  6271. enumerable: true,
  6272. configurable: true
  6273. });
  6274. Object.defineProperty(Image.prototype, "sliceTop", {
  6275. /**
  6276. * Gets or sets the top value for slicing (9-patch)
  6277. */
  6278. get: function () {
  6279. return this._sliceTop;
  6280. },
  6281. set: function (value) {
  6282. if (this._sliceTop === value) {
  6283. return;
  6284. }
  6285. this._sliceTop = value;
  6286. this._markAsDirty();
  6287. },
  6288. enumerable: true,
  6289. configurable: true
  6290. });
  6291. Object.defineProperty(Image.prototype, "sliceBottom", {
  6292. /**
  6293. * Gets or sets the bottom value for slicing (9-patch)
  6294. */
  6295. get: function () {
  6296. return this._sliceBottom;
  6297. },
  6298. set: function (value) {
  6299. if (this._sliceBottom === value) {
  6300. return;
  6301. }
  6302. this._sliceBottom = value;
  6303. this._markAsDirty();
  6304. },
  6305. enumerable: true,
  6306. configurable: true
  6307. });
  6308. Object.defineProperty(Image.prototype, "sourceLeft", {
  6309. /**
  6310. * Gets or sets the left coordinate in the source image
  6311. */
  6312. get: function () {
  6313. return this._sourceLeft;
  6314. },
  6315. set: function (value) {
  6316. if (this._sourceLeft === value) {
  6317. return;
  6318. }
  6319. this._sourceLeft = value;
  6320. this._markAsDirty();
  6321. },
  6322. enumerable: true,
  6323. configurable: true
  6324. });
  6325. Object.defineProperty(Image.prototype, "sourceTop", {
  6326. /**
  6327. * Gets or sets the top coordinate in the source image
  6328. */
  6329. get: function () {
  6330. return this._sourceTop;
  6331. },
  6332. set: function (value) {
  6333. if (this._sourceTop === value) {
  6334. return;
  6335. }
  6336. this._sourceTop = value;
  6337. this._markAsDirty();
  6338. },
  6339. enumerable: true,
  6340. configurable: true
  6341. });
  6342. Object.defineProperty(Image.prototype, "sourceWidth", {
  6343. /**
  6344. * Gets or sets the width to capture in the source image
  6345. */
  6346. get: function () {
  6347. return this._sourceWidth;
  6348. },
  6349. set: function (value) {
  6350. if (this._sourceWidth === value) {
  6351. return;
  6352. }
  6353. this._sourceWidth = value;
  6354. this._markAsDirty();
  6355. },
  6356. enumerable: true,
  6357. configurable: true
  6358. });
  6359. Object.defineProperty(Image.prototype, "sourceHeight", {
  6360. /**
  6361. * Gets or sets the height to capture in the source image
  6362. */
  6363. get: function () {
  6364. return this._sourceHeight;
  6365. },
  6366. set: function (value) {
  6367. if (this._sourceHeight === value) {
  6368. return;
  6369. }
  6370. this._sourceHeight = value;
  6371. this._markAsDirty();
  6372. },
  6373. enumerable: true,
  6374. configurable: true
  6375. });
  6376. Object.defineProperty(Image.prototype, "autoScale", {
  6377. /**
  6378. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6379. * @see http://doc.babylonjs.com/how_to/gui#image
  6380. */
  6381. get: function () {
  6382. return this._autoScale;
  6383. },
  6384. set: function (value) {
  6385. if (this._autoScale === value) {
  6386. return;
  6387. }
  6388. this._autoScale = value;
  6389. if (value && this._loaded) {
  6390. this.synchronizeSizeWithContent();
  6391. }
  6392. },
  6393. enumerable: true,
  6394. configurable: true
  6395. });
  6396. Object.defineProperty(Image.prototype, "stretch", {
  6397. /** Gets or sets the streching mode used by the image */
  6398. get: function () {
  6399. return this._stretch;
  6400. },
  6401. set: function (value) {
  6402. if (this._stretch === value) {
  6403. return;
  6404. }
  6405. this._stretch = value;
  6406. this._markAsDirty();
  6407. },
  6408. enumerable: true,
  6409. configurable: true
  6410. });
  6411. Object.defineProperty(Image.prototype, "domImage", {
  6412. get: function () {
  6413. return this._domImage;
  6414. },
  6415. /**
  6416. * Gets or sets the internal DOM image used to render the control
  6417. */
  6418. set: function (value) {
  6419. var _this = this;
  6420. this._domImage = value;
  6421. this._loaded = false;
  6422. if (this._domImage.width) {
  6423. this._onImageLoaded();
  6424. }
  6425. else {
  6426. this._domImage.onload = function () {
  6427. _this._onImageLoaded();
  6428. };
  6429. }
  6430. },
  6431. enumerable: true,
  6432. configurable: true
  6433. });
  6434. Image.prototype._onImageLoaded = function () {
  6435. this._imageWidth = this._domImage.width;
  6436. this._imageHeight = this._domImage.height;
  6437. this._loaded = true;
  6438. if (this._populateNinePatchSlicesFromImage) {
  6439. this._extractNinePatchSliceDataFromImage();
  6440. }
  6441. if (this._autoScale) {
  6442. this.synchronizeSizeWithContent();
  6443. }
  6444. this.onImageLoadedObservable.notifyObservers(this);
  6445. this._markAsDirty();
  6446. };
  6447. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6448. if (!this._workingCanvas) {
  6449. this._workingCanvas = document.createElement('canvas');
  6450. }
  6451. var canvas = this._workingCanvas;
  6452. var context = canvas.getContext('2d');
  6453. var width = this._domImage.width;
  6454. var height = this._domImage.height;
  6455. canvas.width = width;
  6456. canvas.height = height;
  6457. context.drawImage(this._domImage, 0, 0, width, height);
  6458. var imageData = context.getImageData(0, 0, width, height);
  6459. // Left and right
  6460. this._sliceLeft = -1;
  6461. this._sliceRight = -1;
  6462. for (var x = 0; x < width; x++) {
  6463. var alpha = imageData.data[x * 4 + 3];
  6464. if (alpha > 127 && this._sliceLeft === -1) {
  6465. this._sliceLeft = x;
  6466. continue;
  6467. }
  6468. if (alpha < 127 && this._sliceLeft > -1) {
  6469. this._sliceRight = x;
  6470. break;
  6471. }
  6472. }
  6473. // top and bottom
  6474. this._sliceTop = -1;
  6475. this._sliceBottom = -1;
  6476. for (var y = 0; y < height; y++) {
  6477. var alpha = imageData.data[y * width * 4 + 3];
  6478. if (alpha > 127 && this._sliceTop === -1) {
  6479. this._sliceTop = y;
  6480. continue;
  6481. }
  6482. if (alpha < 127 && this._sliceTop > -1) {
  6483. this._sliceBottom = y;
  6484. break;
  6485. }
  6486. }
  6487. };
  6488. Object.defineProperty(Image.prototype, "source", {
  6489. /**
  6490. * Gets or sets image source url
  6491. */
  6492. set: function (value) {
  6493. var _this = this;
  6494. if (this._source === value) {
  6495. return;
  6496. }
  6497. this._loaded = false;
  6498. this._source = value;
  6499. if (value) {
  6500. value = this._svgCheck(value);
  6501. }
  6502. this._domImage = document.createElement("img");
  6503. this._domImage.onload = function () {
  6504. _this._onImageLoaded();
  6505. };
  6506. if (value) {
  6507. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6508. this._domImage.src = value;
  6509. }
  6510. },
  6511. enumerable: true,
  6512. configurable: true
  6513. });
  6514. /**
  6515. * Checks for svg document with icon id present
  6516. */
  6517. Image.prototype._svgCheck = function (value) {
  6518. var _this = this;
  6519. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6520. var svgsrc = value.split('#')[0];
  6521. var elemid = value.split('#')[1];
  6522. // check if object alr exist in document
  6523. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6524. if (svgExist) {
  6525. // wait for object to load
  6526. svgExist.addEventListener("load", function () {
  6527. _this._getSVGAttribs(svgExist, elemid);
  6528. });
  6529. }
  6530. else {
  6531. // create document object
  6532. var svgImage = document.createElement("object");
  6533. svgImage.data = svgsrc;
  6534. svgImage.type = "image/svg+xml";
  6535. svgImage.width = "0%";
  6536. svgImage.height = "0%";
  6537. document.body.appendChild(svgImage);
  6538. // when the object has loaded, get the element attribs
  6539. svgImage.onload = function () {
  6540. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6541. if (svgobj) {
  6542. _this._getSVGAttribs(svgobj, elemid);
  6543. }
  6544. };
  6545. }
  6546. return svgsrc;
  6547. }
  6548. else {
  6549. return value;
  6550. }
  6551. };
  6552. /**
  6553. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6554. * given external svg file and icon id
  6555. */
  6556. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6557. var svgDoc = svgsrc.contentDocument;
  6558. // get viewbox width and height, get svg document width and height in px
  6559. if (svgDoc && svgDoc.documentElement) {
  6560. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6561. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6562. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6563. // get element bbox and matrix transform
  6564. var elem = svgDoc.getElementById(elemid);
  6565. if (vb && docwidth && docheight) {
  6566. var vb_width = Number(vb.split(" ")[2]);
  6567. var vb_height = Number(vb.split(" ")[3]);
  6568. var elem_bbox = elem.getBBox();
  6569. var elem_matrix_a = 1;
  6570. var elem_matrix_d = 1;
  6571. var elem_matrix_e = 0;
  6572. var elem_matrix_f = 0;
  6573. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6574. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6575. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6576. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6577. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6578. }
  6579. // compute source coordinates and dimensions
  6580. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6581. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6582. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6583. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6584. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6585. }
  6586. }
  6587. };
  6588. Object.defineProperty(Image.prototype, "cellWidth", {
  6589. /**
  6590. * Gets or sets the cell width to use when animation sheet is enabled
  6591. * @see http://doc.babylonjs.com/how_to/gui#image
  6592. */
  6593. get: function () {
  6594. return this._cellWidth;
  6595. },
  6596. set: function (value) {
  6597. if (this._cellWidth === value) {
  6598. return;
  6599. }
  6600. this._cellWidth = value;
  6601. this._markAsDirty();
  6602. },
  6603. enumerable: true,
  6604. configurable: true
  6605. });
  6606. Object.defineProperty(Image.prototype, "cellHeight", {
  6607. /**
  6608. * Gets or sets the cell height to use when animation sheet is enabled
  6609. * @see http://doc.babylonjs.com/how_to/gui#image
  6610. */
  6611. get: function () {
  6612. return this._cellHeight;
  6613. },
  6614. set: function (value) {
  6615. if (this._cellHeight === value) {
  6616. return;
  6617. }
  6618. this._cellHeight = value;
  6619. this._markAsDirty();
  6620. },
  6621. enumerable: true,
  6622. configurable: true
  6623. });
  6624. Object.defineProperty(Image.prototype, "cellId", {
  6625. /**
  6626. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6627. * @see http://doc.babylonjs.com/how_to/gui#image
  6628. */
  6629. get: function () {
  6630. return this._cellId;
  6631. },
  6632. set: function (value) {
  6633. if (this._cellId === value) {
  6634. return;
  6635. }
  6636. this._cellId = value;
  6637. this._markAsDirty();
  6638. },
  6639. enumerable: true,
  6640. configurable: true
  6641. });
  6642. /**
  6643. * Tests if a given coordinates belong to the current control
  6644. * @param x defines x coordinate to test
  6645. * @param y defines y coordinate to test
  6646. * @returns true if the coordinates are inside the control
  6647. */
  6648. Image.prototype.contains = function (x, y) {
  6649. if (!_super.prototype.contains.call(this, x, y)) {
  6650. return false;
  6651. }
  6652. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6653. return true;
  6654. }
  6655. var canvas = this._workingCanvas;
  6656. var context = canvas.getContext("2d");
  6657. var width = this._currentMeasure.width | 0;
  6658. var height = this._currentMeasure.height | 0;
  6659. var imageData = context.getImageData(0, 0, width, height).data;
  6660. x = (x - this._currentMeasure.left) | 0;
  6661. y = (y - this._currentMeasure.top) | 0;
  6662. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6663. return pickedPixel > 0;
  6664. };
  6665. Image.prototype._getTypeName = function () {
  6666. return "Image";
  6667. };
  6668. /** Force the control to synchronize with its content */
  6669. Image.prototype.synchronizeSizeWithContent = function () {
  6670. if (!this._loaded) {
  6671. return;
  6672. }
  6673. this.width = this._domImage.width + "px";
  6674. this.height = this._domImage.height + "px";
  6675. };
  6676. Image.prototype._processMeasures = function (parentMeasure, context) {
  6677. if (this._loaded) {
  6678. switch (this._stretch) {
  6679. case Image.STRETCH_NONE:
  6680. break;
  6681. case Image.STRETCH_FILL:
  6682. break;
  6683. case Image.STRETCH_UNIFORM:
  6684. break;
  6685. case Image.STRETCH_NINE_PATCH:
  6686. break;
  6687. case Image.STRETCH_EXTEND:
  6688. if (this._autoScale) {
  6689. this.synchronizeSizeWithContent();
  6690. }
  6691. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6692. this.parent.adaptWidthToChildren = true;
  6693. this.parent.adaptHeightToChildren = true;
  6694. }
  6695. break;
  6696. }
  6697. }
  6698. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6699. };
  6700. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6701. if (!this._detectPointerOnOpaqueOnly) {
  6702. return;
  6703. }
  6704. if (!this._workingCanvas) {
  6705. this._workingCanvas = document.createElement('canvas');
  6706. }
  6707. var canvas = this._workingCanvas;
  6708. var width = this._currentMeasure.width;
  6709. var height = this._currentMeasure.height;
  6710. var context = canvas.getContext("2d");
  6711. canvas.width = width;
  6712. canvas.height = height;
  6713. context.clearRect(0, 0, width, height);
  6714. };
  6715. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6716. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6717. if (!this._detectPointerOnOpaqueOnly) {
  6718. return;
  6719. }
  6720. var canvas = this._workingCanvas;
  6721. context = canvas.getContext("2d");
  6722. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6723. };
  6724. Image.prototype._draw = function (context) {
  6725. context.save();
  6726. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6727. context.shadowColor = this.shadowColor;
  6728. context.shadowBlur = this.shadowBlur;
  6729. context.shadowOffsetX = this.shadowOffsetX;
  6730. context.shadowOffsetY = this.shadowOffsetY;
  6731. }
  6732. var x, y, width, height;
  6733. if (this.cellId == -1) {
  6734. x = this._sourceLeft;
  6735. y = this._sourceTop;
  6736. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6737. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6738. }
  6739. else {
  6740. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6741. var column = (this.cellId / rowCount) >> 0;
  6742. var row = this.cellId % rowCount;
  6743. x = this.cellWidth * row;
  6744. y = this.cellHeight * column;
  6745. width = this.cellWidth;
  6746. height = this.cellHeight;
  6747. }
  6748. this._prepareWorkingCanvasForOpaqueDetection();
  6749. this._applyStates(context);
  6750. if (this._loaded) {
  6751. switch (this._stretch) {
  6752. case Image.STRETCH_NONE:
  6753. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6754. break;
  6755. case Image.STRETCH_FILL:
  6756. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6757. break;
  6758. case Image.STRETCH_UNIFORM:
  6759. var hRatio = this._currentMeasure.width / width;
  6760. var vRatio = this._currentMeasure.height / height;
  6761. var ratio = Math.min(hRatio, vRatio);
  6762. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6763. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6764. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6765. break;
  6766. case Image.STRETCH_EXTEND:
  6767. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6768. break;
  6769. case Image.STRETCH_NINE_PATCH:
  6770. this._renderNinePatch(context);
  6771. break;
  6772. }
  6773. }
  6774. context.restore();
  6775. };
  6776. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6777. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6778. };
  6779. Image.prototype._renderNinePatch = function (context) {
  6780. var height = this._imageHeight;
  6781. var leftWidth = this._sliceLeft;
  6782. var topHeight = this._sliceTop;
  6783. var bottomHeight = this._imageHeight - this._sliceBottom;
  6784. var rightWidth = this._imageWidth - this._sliceRight;
  6785. var left = 0;
  6786. var top = 0;
  6787. if (this._populateNinePatchSlicesFromImage) {
  6788. left = 1;
  6789. top = 1;
  6790. height -= 2;
  6791. leftWidth -= 1;
  6792. topHeight -= 1;
  6793. bottomHeight -= 1;
  6794. rightWidth -= 1;
  6795. }
  6796. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6797. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6798. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6799. // Corners
  6800. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6801. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6802. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6803. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6804. // Center
  6805. 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);
  6806. // Borders
  6807. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6808. 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);
  6809. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6810. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6811. };
  6812. Image.prototype.dispose = function () {
  6813. _super.prototype.dispose.call(this);
  6814. this.onImageLoadedObservable.clear();
  6815. this.onSVGAttributesComputedObservable.clear();
  6816. };
  6817. // Static
  6818. /** STRETCH_NONE */
  6819. Image.STRETCH_NONE = 0;
  6820. /** STRETCH_FILL */
  6821. Image.STRETCH_FILL = 1;
  6822. /** STRETCH_UNIFORM */
  6823. Image.STRETCH_UNIFORM = 2;
  6824. /** STRETCH_EXTEND */
  6825. Image.STRETCH_EXTEND = 3;
  6826. /** NINE_PATCH */
  6827. Image.STRETCH_NINE_PATCH = 4;
  6828. return Image;
  6829. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6830. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6831. /***/ }),
  6832. /***/ "./2D/controls/index.ts":
  6833. /*!******************************!*\
  6834. !*** ./2D/controls/index.ts ***!
  6835. \******************************/
  6836. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  6837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6838. "use strict";
  6839. __webpack_require__.r(__webpack_exports__);
  6840. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6842. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6844. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6846. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6848. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6850. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6852. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6854. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6856. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6858. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6860. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6862. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6864. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6866. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6868. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6874. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6876. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6879. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6882. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6884. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6886. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6888. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6890. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6892. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6894. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  6895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  6896. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  6898. /***/ }),
  6899. /***/ "./2D/controls/inputPassword.ts":
  6900. /*!**************************************!*\
  6901. !*** ./2D/controls/inputPassword.ts ***!
  6902. \**************************************/
  6903. /*! exports provided: InputPassword */
  6904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6905. "use strict";
  6906. __webpack_require__.r(__webpack_exports__);
  6907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6908. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6909. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6910. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  6911. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6912. /**
  6913. * Class used to create a password control
  6914. */
  6915. var InputPassword = /** @class */ (function (_super) {
  6916. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6917. function InputPassword() {
  6918. return _super !== null && _super.apply(this, arguments) || this;
  6919. }
  6920. InputPassword.prototype._beforeRenderText = function (text) {
  6921. var txt = "";
  6922. for (var i = 0; i < text.length; i++) {
  6923. txt += "\u2022";
  6924. }
  6925. return txt;
  6926. };
  6927. return InputPassword;
  6928. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6929. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6930. /***/ }),
  6931. /***/ "./2D/controls/inputText.ts":
  6932. /*!**********************************!*\
  6933. !*** ./2D/controls/inputText.ts ***!
  6934. \**********************************/
  6935. /*! exports provided: InputText */
  6936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6937. "use strict";
  6938. __webpack_require__.r(__webpack_exports__);
  6939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6940. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6941. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6942. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6943. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6944. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6945. /**
  6946. * Class used to create input text control
  6947. */
  6948. var InputText = /** @class */ (function (_super) {
  6949. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  6950. /**
  6951. * Creates a new InputText
  6952. * @param name defines the control name
  6953. * @param text defines the text of the control
  6954. */
  6955. function InputText(name, text) {
  6956. if (text === void 0) { text = ""; }
  6957. var _this = _super.call(this, name) || this;
  6958. _this.name = name;
  6959. _this._text = "";
  6960. _this._placeholderText = "";
  6961. _this._background = "#222222";
  6962. _this._focusedBackground = "#000000";
  6963. _this._focusedColor = "white";
  6964. _this._placeholderColor = "gray";
  6965. _this._thickness = 1;
  6966. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6967. _this._autoStretchWidth = true;
  6968. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6969. _this._isFocused = false;
  6970. _this._blinkIsEven = false;
  6971. _this._cursorOffset = 0;
  6972. _this._deadKey = false;
  6973. _this._addKey = true;
  6974. _this._currentKey = "";
  6975. _this._isTextHighlightOn = false;
  6976. _this._textHighlightColor = "#d5e0ff";
  6977. _this._highligherOpacity = 0.4;
  6978. _this._highlightedText = "";
  6979. _this._startHighlightIndex = 0;
  6980. _this._endHighlightIndex = 0;
  6981. _this._cursorIndex = -1;
  6982. _this._onFocusSelectAll = false;
  6983. _this._isPointerDown = false;
  6984. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6985. _this.promptMessage = "Please enter text:";
  6986. /** Force disable prompt on mobile device */
  6987. _this.disableMobilePrompt = false;
  6988. /** Observable raised when the text changes */
  6989. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6990. /** Observable raised just before an entered character is to be added */
  6991. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6992. /** Observable raised when the control gets the focus */
  6993. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6994. /** Observable raised when the control loses the focus */
  6995. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6996. /**Observable raised when the text is highlighted */
  6997. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6998. /**Observable raised when copy event is triggered */
  6999. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7000. /** Observable raised when cut event is triggered */
  7001. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7002. /** Observable raised when paste event is triggered */
  7003. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7004. /** Observable raised when a key event was processed */
  7005. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7006. _this.text = text;
  7007. _this.isPointerBlocker = true;
  7008. return _this;
  7009. }
  7010. Object.defineProperty(InputText.prototype, "maxWidth", {
  7011. /** Gets or sets the maximum width allowed by the control */
  7012. get: function () {
  7013. return this._maxWidth.toString(this._host);
  7014. },
  7015. set: function (value) {
  7016. if (this._maxWidth.toString(this._host) === value) {
  7017. return;
  7018. }
  7019. if (this._maxWidth.fromString(value)) {
  7020. this._markAsDirty();
  7021. }
  7022. },
  7023. enumerable: true,
  7024. configurable: true
  7025. });
  7026. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7027. /** Gets the maximum width allowed by the control in pixels */
  7028. get: function () {
  7029. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7030. },
  7031. enumerable: true,
  7032. configurable: true
  7033. });
  7034. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7035. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7036. get: function () {
  7037. return this._highligherOpacity;
  7038. },
  7039. set: function (value) {
  7040. if (this._highligherOpacity === value) {
  7041. return;
  7042. }
  7043. this._highligherOpacity = value;
  7044. this._markAsDirty();
  7045. },
  7046. enumerable: true,
  7047. configurable: true
  7048. });
  7049. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7050. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7051. get: function () {
  7052. return this._onFocusSelectAll;
  7053. },
  7054. set: function (value) {
  7055. if (this._onFocusSelectAll === value) {
  7056. return;
  7057. }
  7058. this._onFocusSelectAll = value;
  7059. this._markAsDirty();
  7060. },
  7061. enumerable: true,
  7062. configurable: true
  7063. });
  7064. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7065. /** Gets or sets the text hightlight color */
  7066. get: function () {
  7067. return this._textHighlightColor;
  7068. },
  7069. set: function (value) {
  7070. if (this._textHighlightColor === value) {
  7071. return;
  7072. }
  7073. this._textHighlightColor = value;
  7074. this._markAsDirty();
  7075. },
  7076. enumerable: true,
  7077. configurable: true
  7078. });
  7079. Object.defineProperty(InputText.prototype, "margin", {
  7080. /** Gets or sets control margin */
  7081. get: function () {
  7082. return this._margin.toString(this._host);
  7083. },
  7084. set: function (value) {
  7085. if (this._margin.toString(this._host) === value) {
  7086. return;
  7087. }
  7088. if (this._margin.fromString(value)) {
  7089. this._markAsDirty();
  7090. }
  7091. },
  7092. enumerable: true,
  7093. configurable: true
  7094. });
  7095. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7096. /** Gets control margin in pixels */
  7097. get: function () {
  7098. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7099. },
  7100. enumerable: true,
  7101. configurable: true
  7102. });
  7103. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7104. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7105. get: function () {
  7106. return this._autoStretchWidth;
  7107. },
  7108. set: function (value) {
  7109. if (this._autoStretchWidth === value) {
  7110. return;
  7111. }
  7112. this._autoStretchWidth = value;
  7113. this._markAsDirty();
  7114. },
  7115. enumerable: true,
  7116. configurable: true
  7117. });
  7118. Object.defineProperty(InputText.prototype, "thickness", {
  7119. /** Gets or sets border thickness */
  7120. get: function () {
  7121. return this._thickness;
  7122. },
  7123. set: function (value) {
  7124. if (this._thickness === value) {
  7125. return;
  7126. }
  7127. this._thickness = value;
  7128. this._markAsDirty();
  7129. },
  7130. enumerable: true,
  7131. configurable: true
  7132. });
  7133. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7134. /** Gets or sets the background color when focused */
  7135. get: function () {
  7136. return this._focusedBackground;
  7137. },
  7138. set: function (value) {
  7139. if (this._focusedBackground === value) {
  7140. return;
  7141. }
  7142. this._focusedBackground = value;
  7143. this._markAsDirty();
  7144. },
  7145. enumerable: true,
  7146. configurable: true
  7147. });
  7148. Object.defineProperty(InputText.prototype, "focusedColor", {
  7149. /** Gets or sets the background color when focused */
  7150. get: function () {
  7151. return this._focusedColor;
  7152. },
  7153. set: function (value) {
  7154. if (this._focusedColor === value) {
  7155. return;
  7156. }
  7157. this._focusedColor = value;
  7158. this._markAsDirty();
  7159. },
  7160. enumerable: true,
  7161. configurable: true
  7162. });
  7163. Object.defineProperty(InputText.prototype, "background", {
  7164. /** Gets or sets the background color */
  7165. get: function () {
  7166. return this._background;
  7167. },
  7168. set: function (value) {
  7169. if (this._background === value) {
  7170. return;
  7171. }
  7172. this._background = value;
  7173. this._markAsDirty();
  7174. },
  7175. enumerable: true,
  7176. configurable: true
  7177. });
  7178. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7179. /** Gets or sets the placeholder color */
  7180. get: function () {
  7181. return this._placeholderColor;
  7182. },
  7183. set: function (value) {
  7184. if (this._placeholderColor === value) {
  7185. return;
  7186. }
  7187. this._placeholderColor = value;
  7188. this._markAsDirty();
  7189. },
  7190. enumerable: true,
  7191. configurable: true
  7192. });
  7193. Object.defineProperty(InputText.prototype, "placeholderText", {
  7194. /** Gets or sets the text displayed when the control is empty */
  7195. get: function () {
  7196. return this._placeholderText;
  7197. },
  7198. set: function (value) {
  7199. if (this._placeholderText === value) {
  7200. return;
  7201. }
  7202. this._placeholderText = value;
  7203. this._markAsDirty();
  7204. },
  7205. enumerable: true,
  7206. configurable: true
  7207. });
  7208. Object.defineProperty(InputText.prototype, "deadKey", {
  7209. /** Gets or sets the dead key flag */
  7210. get: function () {
  7211. return this._deadKey;
  7212. },
  7213. set: function (flag) {
  7214. this._deadKey = flag;
  7215. },
  7216. enumerable: true,
  7217. configurable: true
  7218. });
  7219. Object.defineProperty(InputText.prototype, "highlightedText", {
  7220. /** Gets or sets the highlight text */
  7221. get: function () {
  7222. return this._highlightedText;
  7223. },
  7224. set: function (text) {
  7225. if (this._highlightedText === text) {
  7226. return;
  7227. }
  7228. this._highlightedText = text;
  7229. this._markAsDirty();
  7230. },
  7231. enumerable: true,
  7232. configurable: true
  7233. });
  7234. Object.defineProperty(InputText.prototype, "addKey", {
  7235. /** Gets or sets if the current key should be added */
  7236. get: function () {
  7237. return this._addKey;
  7238. },
  7239. set: function (flag) {
  7240. this._addKey = flag;
  7241. },
  7242. enumerable: true,
  7243. configurable: true
  7244. });
  7245. Object.defineProperty(InputText.prototype, "currentKey", {
  7246. /** Gets or sets the value of the current key being entered */
  7247. get: function () {
  7248. return this._currentKey;
  7249. },
  7250. set: function (key) {
  7251. this._currentKey = key;
  7252. },
  7253. enumerable: true,
  7254. configurable: true
  7255. });
  7256. Object.defineProperty(InputText.prototype, "text", {
  7257. /** Gets or sets the text displayed in the control */
  7258. get: function () {
  7259. return this._text;
  7260. },
  7261. set: function (value) {
  7262. var valueAsString = value.toString(); // Forcing convertion
  7263. if (this._text === valueAsString) {
  7264. return;
  7265. }
  7266. this._text = valueAsString;
  7267. this._markAsDirty();
  7268. this.onTextChangedObservable.notifyObservers(this);
  7269. },
  7270. enumerable: true,
  7271. configurable: true
  7272. });
  7273. Object.defineProperty(InputText.prototype, "width", {
  7274. /** Gets or sets control width */
  7275. get: function () {
  7276. return this._width.toString(this._host);
  7277. },
  7278. set: function (value) {
  7279. if (this._width.toString(this._host) === value) {
  7280. return;
  7281. }
  7282. if (this._width.fromString(value)) {
  7283. this._markAsDirty();
  7284. }
  7285. this.autoStretchWidth = false;
  7286. },
  7287. enumerable: true,
  7288. configurable: true
  7289. });
  7290. /** @hidden */
  7291. InputText.prototype.onBlur = function () {
  7292. this._isFocused = false;
  7293. this._scrollLeft = null;
  7294. this._cursorOffset = 0;
  7295. clearTimeout(this._blinkTimeout);
  7296. this._markAsDirty();
  7297. this.onBlurObservable.notifyObservers(this);
  7298. this._host.unRegisterClipboardEvents();
  7299. if (this._onClipboardObserver) {
  7300. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7301. }
  7302. var scene = this._host.getScene();
  7303. if (this._onPointerDblTapObserver && scene) {
  7304. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7305. }
  7306. };
  7307. /** @hidden */
  7308. InputText.prototype.onFocus = function () {
  7309. var _this = this;
  7310. if (!this._isEnabled) {
  7311. return;
  7312. }
  7313. this._scrollLeft = null;
  7314. this._isFocused = true;
  7315. this._blinkIsEven = false;
  7316. this._cursorOffset = 0;
  7317. this._markAsDirty();
  7318. this.onFocusObservable.notifyObservers(this);
  7319. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7320. var value = prompt(this.promptMessage);
  7321. if (value !== null) {
  7322. this.text = value;
  7323. }
  7324. this._host.focusedControl = null;
  7325. return;
  7326. }
  7327. this._host.registerClipboardEvents();
  7328. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7329. // process clipboard event, can be configured.
  7330. switch (clipboardInfo.type) {
  7331. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7332. _this._onCopyText(clipboardInfo.event);
  7333. _this.onTextCopyObservable.notifyObservers(_this);
  7334. break;
  7335. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7336. _this._onCutText(clipboardInfo.event);
  7337. _this.onTextCutObservable.notifyObservers(_this);
  7338. break;
  7339. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7340. _this._onPasteText(clipboardInfo.event);
  7341. _this.onTextPasteObservable.notifyObservers(_this);
  7342. break;
  7343. default: return;
  7344. }
  7345. });
  7346. var scene = this._host.getScene();
  7347. if (scene) {
  7348. //register the pointer double tap event
  7349. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7350. if (!_this._isFocused) {
  7351. return;
  7352. }
  7353. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7354. _this._processDblClick(pointerInfo);
  7355. }
  7356. });
  7357. }
  7358. if (this._onFocusSelectAll) {
  7359. this._selectAllText();
  7360. }
  7361. };
  7362. InputText.prototype._getTypeName = function () {
  7363. return "InputText";
  7364. };
  7365. /**
  7366. * Function called to get the list of controls that should not steal the focus from this control
  7367. * @returns an array of controls
  7368. */
  7369. InputText.prototype.keepsFocusWith = function () {
  7370. if (!this._connectedVirtualKeyboard) {
  7371. return null;
  7372. }
  7373. return [this._connectedVirtualKeyboard];
  7374. };
  7375. /** @hidden */
  7376. InputText.prototype.processKey = function (keyCode, key, evt) {
  7377. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7378. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7379. return;
  7380. }
  7381. //select all
  7382. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7383. this._selectAllText();
  7384. evt.preventDefault();
  7385. return;
  7386. }
  7387. // Specific cases
  7388. switch (keyCode) {
  7389. case 32: //SPACE
  7390. key = " "; //ie11 key for space is "Spacebar"
  7391. break;
  7392. case 191: //SLASH
  7393. if (evt) {
  7394. evt.preventDefault();
  7395. }
  7396. break;
  7397. case 8: // BACKSPACE
  7398. if (this._text && this._text.length > 0) {
  7399. //delete the highlighted text
  7400. if (this._isTextHighlightOn) {
  7401. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7402. this._isTextHighlightOn = false;
  7403. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7404. this._blinkIsEven = false;
  7405. if (evt) {
  7406. evt.preventDefault();
  7407. }
  7408. return;
  7409. }
  7410. //delete single character
  7411. if (this._cursorOffset === 0) {
  7412. this.text = this._text.substr(0, this._text.length - 1);
  7413. }
  7414. else {
  7415. var deletePosition = this._text.length - this._cursorOffset;
  7416. if (deletePosition > 0) {
  7417. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7418. }
  7419. }
  7420. }
  7421. if (evt) {
  7422. evt.preventDefault();
  7423. }
  7424. return;
  7425. case 46: // DELETE
  7426. if (this._isTextHighlightOn) {
  7427. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7428. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7429. while (decrementor > 0 && this._cursorOffset > 0) {
  7430. this._cursorOffset--;
  7431. }
  7432. this._isTextHighlightOn = false;
  7433. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7434. if (evt) {
  7435. evt.preventDefault();
  7436. }
  7437. return;
  7438. }
  7439. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7440. var deletePosition = this._text.length - this._cursorOffset;
  7441. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7442. this._cursorOffset--;
  7443. }
  7444. if (evt) {
  7445. evt.preventDefault();
  7446. }
  7447. return;
  7448. case 13: // RETURN
  7449. this._host.focusedControl = null;
  7450. this._isTextHighlightOn = false;
  7451. return;
  7452. case 35: // END
  7453. this._cursorOffset = 0;
  7454. this._blinkIsEven = false;
  7455. this._isTextHighlightOn = false;
  7456. this._markAsDirty();
  7457. return;
  7458. case 36: // HOME
  7459. this._cursorOffset = this._text.length;
  7460. this._blinkIsEven = false;
  7461. this._isTextHighlightOn = false;
  7462. this._markAsDirty();
  7463. return;
  7464. case 37: // LEFT
  7465. this._cursorOffset++;
  7466. if (this._cursorOffset > this._text.length) {
  7467. this._cursorOffset = this._text.length;
  7468. }
  7469. if (evt && evt.shiftKey) {
  7470. // update the cursor
  7471. this._blinkIsEven = false;
  7472. // shift + ctrl/cmd + <-
  7473. if (evt.ctrlKey || evt.metaKey) {
  7474. if (!this._isTextHighlightOn) {
  7475. if (this._text.length === this._cursorOffset) {
  7476. return;
  7477. }
  7478. else {
  7479. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7480. }
  7481. }
  7482. this._startHighlightIndex = 0;
  7483. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7484. this._cursorOffset = this._text.length;
  7485. this._isTextHighlightOn = true;
  7486. this._markAsDirty();
  7487. return;
  7488. }
  7489. //store the starting point
  7490. if (!this._isTextHighlightOn) {
  7491. this._isTextHighlightOn = true;
  7492. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7493. }
  7494. //if text is already highlighted
  7495. else if (this._cursorIndex === -1) {
  7496. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7497. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7498. }
  7499. //set the highlight indexes
  7500. if (this._cursorIndex < this._cursorOffset) {
  7501. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7502. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7503. }
  7504. else if (this._cursorIndex > this._cursorOffset) {
  7505. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7506. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7507. }
  7508. else {
  7509. this._isTextHighlightOn = false;
  7510. }
  7511. this._markAsDirty();
  7512. return;
  7513. }
  7514. if (this._isTextHighlightOn) {
  7515. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7516. this._isTextHighlightOn = false;
  7517. }
  7518. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7519. this._cursorOffset = this.text.length;
  7520. evt.preventDefault();
  7521. }
  7522. this._blinkIsEven = false;
  7523. this._isTextHighlightOn = false;
  7524. this._cursorIndex = -1;
  7525. this._markAsDirty();
  7526. return;
  7527. case 39: // RIGHT
  7528. this._cursorOffset--;
  7529. if (this._cursorOffset < 0) {
  7530. this._cursorOffset = 0;
  7531. }
  7532. if (evt && evt.shiftKey) {
  7533. //update the cursor
  7534. this._blinkIsEven = false;
  7535. //shift + ctrl/cmd + ->
  7536. if (evt.ctrlKey || evt.metaKey) {
  7537. if (!this._isTextHighlightOn) {
  7538. if (this._cursorOffset === 0) {
  7539. return;
  7540. }
  7541. else {
  7542. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7543. }
  7544. }
  7545. this._endHighlightIndex = this._text.length;
  7546. this._isTextHighlightOn = true;
  7547. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7548. this._cursorOffset = 0;
  7549. this._markAsDirty();
  7550. return;
  7551. }
  7552. if (!this._isTextHighlightOn) {
  7553. this._isTextHighlightOn = true;
  7554. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7555. }
  7556. //if text is already highlighted
  7557. else if (this._cursorIndex === -1) {
  7558. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7559. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7560. }
  7561. //set the highlight indexes
  7562. if (this._cursorIndex < this._cursorOffset) {
  7563. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7564. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7565. }
  7566. else if (this._cursorIndex > this._cursorOffset) {
  7567. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7568. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7569. }
  7570. else {
  7571. this._isTextHighlightOn = false;
  7572. }
  7573. this._markAsDirty();
  7574. return;
  7575. }
  7576. if (this._isTextHighlightOn) {
  7577. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7578. this._isTextHighlightOn = false;
  7579. }
  7580. //ctr + ->
  7581. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7582. this._cursorOffset = 0;
  7583. evt.preventDefault();
  7584. }
  7585. this._blinkIsEven = false;
  7586. this._isTextHighlightOn = false;
  7587. this._cursorIndex = -1;
  7588. this._markAsDirty();
  7589. return;
  7590. case 222: // Dead
  7591. if (evt) {
  7592. evt.preventDefault();
  7593. }
  7594. this._cursorIndex = -1;
  7595. this.deadKey = true;
  7596. break;
  7597. }
  7598. // Printable characters
  7599. if (key &&
  7600. ((keyCode === -1) || // Direct access
  7601. (keyCode === 32) || // Space
  7602. (keyCode > 47 && keyCode < 64) || // Numbers
  7603. (keyCode > 64 && keyCode < 91) || // Letters
  7604. (keyCode > 159 && keyCode < 193) || // Special characters
  7605. (keyCode > 218 && keyCode < 223) || // Special characters
  7606. (keyCode > 95 && keyCode < 112))) { // Numpad
  7607. this._currentKey = key;
  7608. this.onBeforeKeyAddObservable.notifyObservers(this);
  7609. key = this._currentKey;
  7610. if (this._addKey) {
  7611. if (this._isTextHighlightOn) {
  7612. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7613. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7614. this._isTextHighlightOn = false;
  7615. this._blinkIsEven = false;
  7616. this._markAsDirty();
  7617. }
  7618. else if (this._cursorOffset === 0) {
  7619. this.text += key;
  7620. }
  7621. else {
  7622. var insertPosition = this._text.length - this._cursorOffset;
  7623. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7624. }
  7625. }
  7626. }
  7627. };
  7628. /** @hidden */
  7629. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7630. //update the cursor
  7631. this._blinkIsEven = false;
  7632. if (this._cursorIndex === -1) {
  7633. this._cursorIndex = offset;
  7634. }
  7635. else {
  7636. if (this._cursorIndex < this._cursorOffset) {
  7637. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7638. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7639. }
  7640. else if (this._cursorIndex > this._cursorOffset) {
  7641. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7642. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7643. }
  7644. else {
  7645. this._isTextHighlightOn = false;
  7646. this._markAsDirty();
  7647. return;
  7648. }
  7649. }
  7650. this._isTextHighlightOn = true;
  7651. this._markAsDirty();
  7652. };
  7653. /** @hidden */
  7654. InputText.prototype._processDblClick = function (evt) {
  7655. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7656. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7657. this._endHighlightIndex = this._startHighlightIndex;
  7658. var rWord = /\w+/g, moveLeft, moveRight;
  7659. do {
  7660. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7661. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7662. } while (moveLeft || moveRight);
  7663. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7664. this.onTextHighlightObservable.notifyObservers(this);
  7665. this._isTextHighlightOn = true;
  7666. this._clickedCoordinate = null;
  7667. this._blinkIsEven = true;
  7668. this._cursorIndex = -1;
  7669. this._markAsDirty();
  7670. };
  7671. /** @hidden */
  7672. InputText.prototype._selectAllText = function () {
  7673. this._blinkIsEven = true;
  7674. this._isTextHighlightOn = true;
  7675. this._startHighlightIndex = 0;
  7676. this._endHighlightIndex = this._text.length;
  7677. this._cursorOffset = this._text.length;
  7678. this._cursorIndex = -1;
  7679. this._markAsDirty();
  7680. };
  7681. /**
  7682. * Handles the keyboard event
  7683. * @param evt Defines the KeyboardEvent
  7684. */
  7685. InputText.prototype.processKeyboard = function (evt) {
  7686. // process pressed key
  7687. this.processKey(evt.keyCode, evt.key, evt);
  7688. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7689. };
  7690. /** @hidden */
  7691. InputText.prototype._onCopyText = function (ev) {
  7692. this._isTextHighlightOn = false;
  7693. //when write permission to clipbaord data is denied
  7694. try {
  7695. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7696. }
  7697. catch (_a) { } //pass
  7698. this._host.clipboardData = this._highlightedText;
  7699. };
  7700. /** @hidden */
  7701. InputText.prototype._onCutText = function (ev) {
  7702. if (!this._highlightedText) {
  7703. return;
  7704. }
  7705. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7706. this._isTextHighlightOn = false;
  7707. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7708. //when write permission to clipbaord data is denied
  7709. try {
  7710. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7711. }
  7712. catch (_a) { } //pass
  7713. this._host.clipboardData = this._highlightedText;
  7714. this._highlightedText = "";
  7715. };
  7716. /** @hidden */
  7717. InputText.prototype._onPasteText = function (ev) {
  7718. var data = "";
  7719. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7720. data = ev.clipboardData.getData("text/plain");
  7721. }
  7722. else {
  7723. //get the cached data; returns blank string by default
  7724. data = this._host.clipboardData;
  7725. }
  7726. var insertPosition = this._text.length - this._cursorOffset;
  7727. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7728. };
  7729. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7730. var _this = this;
  7731. context.save();
  7732. this._applyStates(context);
  7733. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7734. context.shadowColor = this.shadowColor;
  7735. context.shadowBlur = this.shadowBlur;
  7736. context.shadowOffsetX = this.shadowOffsetX;
  7737. context.shadowOffsetY = this.shadowOffsetY;
  7738. }
  7739. // Background
  7740. if (this._isFocused) {
  7741. if (this._focusedBackground) {
  7742. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7743. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7744. }
  7745. }
  7746. else if (this._background) {
  7747. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7748. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7749. }
  7750. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7751. context.shadowBlur = 0;
  7752. context.shadowOffsetX = 0;
  7753. context.shadowOffsetY = 0;
  7754. }
  7755. if (!this._fontOffset) {
  7756. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7757. }
  7758. // Text
  7759. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7760. if (this.color) {
  7761. context.fillStyle = this.color;
  7762. }
  7763. var text = this._beforeRenderText(this._text);
  7764. if (!this._isFocused && !this._text && this._placeholderText) {
  7765. text = this._placeholderText;
  7766. if (this._placeholderColor) {
  7767. context.fillStyle = this._placeholderColor;
  7768. }
  7769. }
  7770. this._textWidth = context.measureText(text).width;
  7771. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7772. if (this._autoStretchWidth) {
  7773. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7774. }
  7775. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7776. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7777. context.save();
  7778. context.beginPath();
  7779. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7780. context.clip();
  7781. if (this._isFocused && this._textWidth > availableWidth) {
  7782. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7783. if (!this._scrollLeft) {
  7784. this._scrollLeft = textLeft;
  7785. }
  7786. }
  7787. else {
  7788. this._scrollLeft = clipTextLeft;
  7789. }
  7790. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7791. // Cursor
  7792. if (this._isFocused) {
  7793. // Need to move cursor
  7794. if (this._clickedCoordinate) {
  7795. var rightPosition = this._scrollLeft + this._textWidth;
  7796. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7797. var currentSize = 0;
  7798. this._cursorOffset = 0;
  7799. var previousDist = 0;
  7800. do {
  7801. if (this._cursorOffset) {
  7802. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7803. }
  7804. this._cursorOffset++;
  7805. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7806. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7807. // Find closest move
  7808. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7809. this._cursorOffset--;
  7810. }
  7811. this._blinkIsEven = false;
  7812. this._clickedCoordinate = null;
  7813. }
  7814. // Render cursor
  7815. if (!this._blinkIsEven) {
  7816. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7817. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7818. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7819. if (cursorLeft < clipTextLeft) {
  7820. this._scrollLeft += (clipTextLeft - cursorLeft);
  7821. cursorLeft = clipTextLeft;
  7822. this._markAsDirty();
  7823. }
  7824. else if (cursorLeft > clipTextLeft + availableWidth) {
  7825. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7826. cursorLeft = clipTextLeft + availableWidth;
  7827. this._markAsDirty();
  7828. }
  7829. if (!this._isTextHighlightOn) {
  7830. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7831. }
  7832. }
  7833. clearTimeout(this._blinkTimeout);
  7834. this._blinkTimeout = setTimeout(function () {
  7835. _this._blinkIsEven = !_this._blinkIsEven;
  7836. _this._markAsDirty();
  7837. }, 500);
  7838. //show the highlighted text
  7839. if (this._isTextHighlightOn) {
  7840. clearTimeout(this._blinkTimeout);
  7841. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7842. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7843. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7844. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7845. if (highlightCursorLeft < clipTextLeft) {
  7846. width = width - (clipTextLeft - highlightCursorLeft);
  7847. if (!width) {
  7848. // when using left arrow on text.length > availableWidth;
  7849. // assigns the width of the first letter after clipTextLeft
  7850. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7851. }
  7852. highlightCursorLeft = clipTextLeft;
  7853. }
  7854. //for transparancy
  7855. context.globalAlpha = this._highligherOpacity;
  7856. context.fillStyle = this._textHighlightColor;
  7857. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7858. context.globalAlpha = 1.0;
  7859. }
  7860. }
  7861. context.restore();
  7862. // Border
  7863. if (this._thickness) {
  7864. if (this._isFocused) {
  7865. if (this.focusedColor) {
  7866. context.strokeStyle = this.focusedColor;
  7867. }
  7868. }
  7869. else {
  7870. if (this.color) {
  7871. context.strokeStyle = this.color;
  7872. }
  7873. }
  7874. context.lineWidth = this._thickness;
  7875. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7876. }
  7877. context.restore();
  7878. };
  7879. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7880. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7881. return false;
  7882. }
  7883. this._clickedCoordinate = coordinates.x;
  7884. this._isTextHighlightOn = false;
  7885. this._highlightedText = "";
  7886. this._cursorIndex = -1;
  7887. this._isPointerDown = true;
  7888. this._host._capturingControl[pointerId] = this;
  7889. if (this._host.focusedControl === this) {
  7890. // Move cursor
  7891. clearTimeout(this._blinkTimeout);
  7892. this._markAsDirty();
  7893. return true;
  7894. }
  7895. if (!this._isEnabled) {
  7896. return false;
  7897. }
  7898. this._host.focusedControl = this;
  7899. return true;
  7900. };
  7901. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7902. if (this._host.focusedControl === this && this._isPointerDown) {
  7903. this._clickedCoordinate = coordinates.x;
  7904. this._markAsDirty();
  7905. this._updateValueFromCursorIndex(this._cursorOffset);
  7906. }
  7907. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7908. };
  7909. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7910. this._isPointerDown = false;
  7911. delete this._host._capturingControl[pointerId];
  7912. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7913. };
  7914. InputText.prototype._beforeRenderText = function (text) {
  7915. return text;
  7916. };
  7917. InputText.prototype.dispose = function () {
  7918. _super.prototype.dispose.call(this);
  7919. this.onBlurObservable.clear();
  7920. this.onFocusObservable.clear();
  7921. this.onTextChangedObservable.clear();
  7922. this.onTextCopyObservable.clear();
  7923. this.onTextCutObservable.clear();
  7924. this.onTextPasteObservable.clear();
  7925. this.onTextHighlightObservable.clear();
  7926. this.onKeyboardEventProcessedObservable.clear();
  7927. };
  7928. return InputText;
  7929. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7930. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7931. /***/ }),
  7932. /***/ "./2D/controls/line.ts":
  7933. /*!*****************************!*\
  7934. !*** ./2D/controls/line.ts ***!
  7935. \*****************************/
  7936. /*! exports provided: Line */
  7937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7938. "use strict";
  7939. __webpack_require__.r(__webpack_exports__);
  7940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7941. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7942. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7943. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7944. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7945. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7946. /** Class used to render 2D lines */
  7947. var Line = /** @class */ (function (_super) {
  7948. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  7949. /**
  7950. * Creates a new Line
  7951. * @param name defines the control name
  7952. */
  7953. function Line(name) {
  7954. var _this = _super.call(this, name) || this;
  7955. _this.name = name;
  7956. _this._lineWidth = 1;
  7957. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7958. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7959. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7960. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7961. _this._dash = new Array();
  7962. _this._automaticSize = true;
  7963. _this.isHitTestVisible = false;
  7964. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7965. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7966. return _this;
  7967. }
  7968. Object.defineProperty(Line.prototype, "dash", {
  7969. /** Gets or sets the dash pattern */
  7970. get: function () {
  7971. return this._dash;
  7972. },
  7973. set: function (value) {
  7974. if (this._dash === value) {
  7975. return;
  7976. }
  7977. this._dash = value;
  7978. this._markAsDirty();
  7979. },
  7980. enumerable: true,
  7981. configurable: true
  7982. });
  7983. Object.defineProperty(Line.prototype, "connectedControl", {
  7984. /** Gets or sets the control connected with the line end */
  7985. get: function () {
  7986. return this._connectedControl;
  7987. },
  7988. set: function (value) {
  7989. var _this = this;
  7990. if (this._connectedControl === value) {
  7991. return;
  7992. }
  7993. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7994. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7995. this._connectedControlDirtyObserver = null;
  7996. }
  7997. if (value) {
  7998. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7999. }
  8000. this._connectedControl = value;
  8001. this._markAsDirty();
  8002. },
  8003. enumerable: true,
  8004. configurable: true
  8005. });
  8006. Object.defineProperty(Line.prototype, "x1", {
  8007. /** Gets or sets start coordinates on X axis */
  8008. get: function () {
  8009. return this._x1.toString(this._host);
  8010. },
  8011. set: function (value) {
  8012. if (this._x1.toString(this._host) === value) {
  8013. return;
  8014. }
  8015. if (this._x1.fromString(value)) {
  8016. this._markAsDirty();
  8017. }
  8018. },
  8019. enumerable: true,
  8020. configurable: true
  8021. });
  8022. Object.defineProperty(Line.prototype, "y1", {
  8023. /** Gets or sets start coordinates on Y axis */
  8024. get: function () {
  8025. return this._y1.toString(this._host);
  8026. },
  8027. set: function (value) {
  8028. if (this._y1.toString(this._host) === value) {
  8029. return;
  8030. }
  8031. if (this._y1.fromString(value)) {
  8032. this._markAsDirty();
  8033. }
  8034. },
  8035. enumerable: true,
  8036. configurable: true
  8037. });
  8038. Object.defineProperty(Line.prototype, "x2", {
  8039. /** Gets or sets end coordinates on X axis */
  8040. get: function () {
  8041. return this._x2.toString(this._host);
  8042. },
  8043. set: function (value) {
  8044. if (this._x2.toString(this._host) === value) {
  8045. return;
  8046. }
  8047. if (this._x2.fromString(value)) {
  8048. this._markAsDirty();
  8049. }
  8050. },
  8051. enumerable: true,
  8052. configurable: true
  8053. });
  8054. Object.defineProperty(Line.prototype, "y2", {
  8055. /** Gets or sets end coordinates on Y axis */
  8056. get: function () {
  8057. return this._y2.toString(this._host);
  8058. },
  8059. set: function (value) {
  8060. if (this._y2.toString(this._host) === value) {
  8061. return;
  8062. }
  8063. if (this._y2.fromString(value)) {
  8064. this._markAsDirty();
  8065. }
  8066. },
  8067. enumerable: true,
  8068. configurable: true
  8069. });
  8070. Object.defineProperty(Line.prototype, "lineWidth", {
  8071. /** Gets or sets line width */
  8072. get: function () {
  8073. return this._lineWidth;
  8074. },
  8075. set: function (value) {
  8076. if (this._lineWidth === value) {
  8077. return;
  8078. }
  8079. this._lineWidth = value;
  8080. this._markAsDirty();
  8081. },
  8082. enumerable: true,
  8083. configurable: true
  8084. });
  8085. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8086. /** Gets or sets horizontal alignment */
  8087. set: function (value) {
  8088. return;
  8089. },
  8090. enumerable: true,
  8091. configurable: true
  8092. });
  8093. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8094. /** Gets or sets vertical alignment */
  8095. set: function (value) {
  8096. return;
  8097. },
  8098. enumerable: true,
  8099. configurable: true
  8100. });
  8101. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8102. get: function () {
  8103. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8104. },
  8105. enumerable: true,
  8106. configurable: true
  8107. });
  8108. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8109. get: function () {
  8110. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8111. },
  8112. enumerable: true,
  8113. configurable: true
  8114. });
  8115. Line.prototype._getTypeName = function () {
  8116. return "Line";
  8117. };
  8118. Line.prototype._draw = function (context) {
  8119. context.save();
  8120. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8121. context.shadowColor = this.shadowColor;
  8122. context.shadowBlur = this.shadowBlur;
  8123. context.shadowOffsetX = this.shadowOffsetX;
  8124. context.shadowOffsetY = this.shadowOffsetY;
  8125. }
  8126. this._applyStates(context);
  8127. context.strokeStyle = this.color;
  8128. context.lineWidth = this._lineWidth;
  8129. context.setLineDash(this._dash);
  8130. context.beginPath();
  8131. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8132. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8133. context.stroke();
  8134. context.restore();
  8135. };
  8136. Line.prototype._measure = function () {
  8137. // Width / Height
  8138. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8139. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8140. };
  8141. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8142. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8143. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8144. };
  8145. /**
  8146. * Move one end of the line given 3D cartesian coordinates.
  8147. * @param position Targeted world position
  8148. * @param scene Scene
  8149. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8150. */
  8151. Line.prototype.moveToVector3 = function (position, scene, end) {
  8152. if (end === void 0) { end = false; }
  8153. if (!this._host || this.parent !== this._host._rootContainer) {
  8154. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8155. return;
  8156. }
  8157. var globalViewport = this._host._getGlobalViewport(scene);
  8158. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8159. this._moveToProjectedPosition(projectedPosition, end);
  8160. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8161. this.notRenderable = true;
  8162. return;
  8163. }
  8164. this.notRenderable = false;
  8165. };
  8166. /**
  8167. * Move one end of the line to a position in screen absolute space.
  8168. * @param projectedPosition Position in screen absolute space (X, Y)
  8169. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8170. */
  8171. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8172. if (end === void 0) { end = false; }
  8173. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8174. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8175. if (end) {
  8176. this.x2 = x;
  8177. this.y2 = y;
  8178. this._x2.ignoreAdaptiveScaling = true;
  8179. this._y2.ignoreAdaptiveScaling = true;
  8180. }
  8181. else {
  8182. this.x1 = x;
  8183. this.y1 = y;
  8184. this._x1.ignoreAdaptiveScaling = true;
  8185. this._y1.ignoreAdaptiveScaling = true;
  8186. }
  8187. };
  8188. return Line;
  8189. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8190. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8191. /***/ }),
  8192. /***/ "./2D/controls/multiLine.ts":
  8193. /*!**********************************!*\
  8194. !*** ./2D/controls/multiLine.ts ***!
  8195. \**********************************/
  8196. /*! exports provided: MultiLine */
  8197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8198. "use strict";
  8199. __webpack_require__.r(__webpack_exports__);
  8200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8201. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8202. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8203. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8204. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8205. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8206. /**
  8207. * Class used to create multi line control
  8208. */
  8209. var MultiLine = /** @class */ (function (_super) {
  8210. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8211. /**
  8212. * Creates a new MultiLine
  8213. * @param name defines the control name
  8214. */
  8215. function MultiLine(name) {
  8216. var _this = _super.call(this, name) || this;
  8217. _this.name = name;
  8218. _this._lineWidth = 1;
  8219. /** Function called when a point is updated */
  8220. _this.onPointUpdate = function () {
  8221. _this._markAsDirty();
  8222. };
  8223. _this._automaticSize = true;
  8224. _this.isHitTestVisible = false;
  8225. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8226. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8227. _this._dash = [];
  8228. _this._points = [];
  8229. return _this;
  8230. }
  8231. Object.defineProperty(MultiLine.prototype, "dash", {
  8232. /** Gets or sets dash pattern */
  8233. get: function () {
  8234. return this._dash;
  8235. },
  8236. set: function (value) {
  8237. if (this._dash === value) {
  8238. return;
  8239. }
  8240. this._dash = value;
  8241. this._markAsDirty();
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. /**
  8247. * Gets point stored at specified index
  8248. * @param index defines the index to look for
  8249. * @returns the requested point if found
  8250. */
  8251. MultiLine.prototype.getAt = function (index) {
  8252. if (!this._points[index]) {
  8253. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8254. }
  8255. return this._points[index];
  8256. };
  8257. /**
  8258. * Adds new points to the point collection
  8259. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8260. * @returns the list of created MultiLinePoint
  8261. */
  8262. MultiLine.prototype.add = function () {
  8263. var _this = this;
  8264. var items = [];
  8265. for (var _i = 0; _i < arguments.length; _i++) {
  8266. items[_i] = arguments[_i];
  8267. }
  8268. return items.map(function (item) { return _this.push(item); });
  8269. };
  8270. /**
  8271. * Adds a new point to the point collection
  8272. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8273. * @returns the created MultiLinePoint
  8274. */
  8275. MultiLine.prototype.push = function (item) {
  8276. var point = this.getAt(this._points.length);
  8277. if (item == null) {
  8278. return point;
  8279. }
  8280. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8281. point.mesh = item;
  8282. }
  8283. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8284. point.control = item;
  8285. }
  8286. else if (item.x != null && item.y != null) {
  8287. point.x = item.x;
  8288. point.y = item.y;
  8289. }
  8290. return point;
  8291. };
  8292. /**
  8293. * Remove a specific value or point from the active point collection
  8294. * @param value defines the value or point to remove
  8295. */
  8296. MultiLine.prototype.remove = function (value) {
  8297. var index;
  8298. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8299. index = this._points.indexOf(value);
  8300. if (index === -1) {
  8301. return;
  8302. }
  8303. }
  8304. else {
  8305. index = value;
  8306. }
  8307. var point = this._points[index];
  8308. if (!point) {
  8309. return;
  8310. }
  8311. point.dispose();
  8312. this._points.splice(index, 1);
  8313. };
  8314. /**
  8315. * Resets this object to initial state (no point)
  8316. */
  8317. MultiLine.prototype.reset = function () {
  8318. while (this._points.length > 0) {
  8319. this.remove(this._points.length - 1);
  8320. }
  8321. };
  8322. /**
  8323. * Resets all links
  8324. */
  8325. MultiLine.prototype.resetLinks = function () {
  8326. this._points.forEach(function (point) {
  8327. if (point != null) {
  8328. point.resetLinks();
  8329. }
  8330. });
  8331. };
  8332. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8333. /** Gets or sets line width */
  8334. get: function () {
  8335. return this._lineWidth;
  8336. },
  8337. set: function (value) {
  8338. if (this._lineWidth === value) {
  8339. return;
  8340. }
  8341. this._lineWidth = value;
  8342. this._markAsDirty();
  8343. },
  8344. enumerable: true,
  8345. configurable: true
  8346. });
  8347. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8348. set: function (value) {
  8349. return;
  8350. },
  8351. enumerable: true,
  8352. configurable: true
  8353. });
  8354. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8355. set: function (value) {
  8356. return;
  8357. },
  8358. enumerable: true,
  8359. configurable: true
  8360. });
  8361. MultiLine.prototype._getTypeName = function () {
  8362. return "MultiLine";
  8363. };
  8364. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8365. context.save();
  8366. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8367. context.shadowColor = this.shadowColor;
  8368. context.shadowBlur = this.shadowBlur;
  8369. context.shadowOffsetX = this.shadowOffsetX;
  8370. context.shadowOffsetY = this.shadowOffsetY;
  8371. }
  8372. this._applyStates(context);
  8373. context.strokeStyle = this.color;
  8374. context.lineWidth = this._lineWidth;
  8375. context.setLineDash(this._dash);
  8376. context.beginPath();
  8377. var first = true; //first index is not necessarily 0
  8378. this._points.forEach(function (point) {
  8379. if (!point) {
  8380. return;
  8381. }
  8382. if (first) {
  8383. context.moveTo(point._point.x, point._point.y);
  8384. first = false;
  8385. }
  8386. else {
  8387. context.lineTo(point._point.x, point._point.y);
  8388. }
  8389. });
  8390. context.stroke();
  8391. context.restore();
  8392. };
  8393. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8394. var _this = this;
  8395. this._minX = null;
  8396. this._minY = null;
  8397. this._maxX = null;
  8398. this._maxY = null;
  8399. this._points.forEach(function (point, index) {
  8400. if (!point) {
  8401. return;
  8402. }
  8403. point.translate();
  8404. if (_this._minX == null || point._point.x < _this._minX) {
  8405. _this._minX = point._point.x;
  8406. }
  8407. if (_this._minY == null || point._point.y < _this._minY) {
  8408. _this._minY = point._point.y;
  8409. }
  8410. if (_this._maxX == null || point._point.x > _this._maxX) {
  8411. _this._maxX = point._point.x;
  8412. }
  8413. if (_this._maxY == null || point._point.y > _this._maxY) {
  8414. _this._maxY = point._point.y;
  8415. }
  8416. });
  8417. if (this._minX == null) {
  8418. this._minX = 0;
  8419. }
  8420. if (this._minY == null) {
  8421. this._minY = 0;
  8422. }
  8423. if (this._maxX == null) {
  8424. this._maxX = 0;
  8425. }
  8426. if (this._maxY == null) {
  8427. this._maxY = 0;
  8428. }
  8429. };
  8430. MultiLine.prototype._measure = function () {
  8431. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8432. return;
  8433. }
  8434. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8435. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8436. };
  8437. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8438. if (this._minX == null || this._minY == null) {
  8439. return;
  8440. }
  8441. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8442. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8443. };
  8444. MultiLine.prototype.dispose = function () {
  8445. this.reset();
  8446. _super.prototype.dispose.call(this);
  8447. };
  8448. return MultiLine;
  8449. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8450. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8451. /***/ }),
  8452. /***/ "./2D/controls/radioButton.ts":
  8453. /*!************************************!*\
  8454. !*** ./2D/controls/radioButton.ts ***!
  8455. \************************************/
  8456. /*! exports provided: RadioButton */
  8457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8458. "use strict";
  8459. __webpack_require__.r(__webpack_exports__);
  8460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8461. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8462. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8463. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8464. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8465. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8466. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8467. /**
  8468. * Class used to create radio button controls
  8469. */
  8470. var RadioButton = /** @class */ (function (_super) {
  8471. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8472. /**
  8473. * Creates a new RadioButton
  8474. * @param name defines the control name
  8475. */
  8476. function RadioButton(name) {
  8477. var _this = _super.call(this, name) || this;
  8478. _this.name = name;
  8479. _this._isChecked = false;
  8480. _this._background = "black";
  8481. _this._checkSizeRatio = 0.8;
  8482. _this._thickness = 1;
  8483. /** Gets or sets group name */
  8484. _this.group = "";
  8485. /** Observable raised when isChecked is changed */
  8486. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8487. _this.isPointerBlocker = true;
  8488. return _this;
  8489. }
  8490. Object.defineProperty(RadioButton.prototype, "thickness", {
  8491. /** Gets or sets border thickness */
  8492. get: function () {
  8493. return this._thickness;
  8494. },
  8495. set: function (value) {
  8496. if (this._thickness === value) {
  8497. return;
  8498. }
  8499. this._thickness = value;
  8500. this._markAsDirty();
  8501. },
  8502. enumerable: true,
  8503. configurable: true
  8504. });
  8505. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8506. /** Gets or sets a value indicating the ratio between overall size and check size */
  8507. get: function () {
  8508. return this._checkSizeRatio;
  8509. },
  8510. set: function (value) {
  8511. value = Math.max(Math.min(1, value), 0);
  8512. if (this._checkSizeRatio === value) {
  8513. return;
  8514. }
  8515. this._checkSizeRatio = value;
  8516. this._markAsDirty();
  8517. },
  8518. enumerable: true,
  8519. configurable: true
  8520. });
  8521. Object.defineProperty(RadioButton.prototype, "background", {
  8522. /** Gets or sets background color */
  8523. get: function () {
  8524. return this._background;
  8525. },
  8526. set: function (value) {
  8527. if (this._background === value) {
  8528. return;
  8529. }
  8530. this._background = value;
  8531. this._markAsDirty();
  8532. },
  8533. enumerable: true,
  8534. configurable: true
  8535. });
  8536. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8537. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8538. get: function () {
  8539. return this._isChecked;
  8540. },
  8541. set: function (value) {
  8542. var _this = this;
  8543. if (this._isChecked === value) {
  8544. return;
  8545. }
  8546. this._isChecked = value;
  8547. this._markAsDirty();
  8548. this.onIsCheckedChangedObservable.notifyObservers(value);
  8549. if (this._isChecked && this._host) {
  8550. // Update all controls from same group
  8551. this._host.executeOnAllControls(function (control) {
  8552. if (control === _this) {
  8553. return;
  8554. }
  8555. if (control.group === undefined) {
  8556. return;
  8557. }
  8558. var childRadio = control;
  8559. if (childRadio.group === _this.group) {
  8560. childRadio.isChecked = false;
  8561. }
  8562. });
  8563. }
  8564. },
  8565. enumerable: true,
  8566. configurable: true
  8567. });
  8568. RadioButton.prototype._getTypeName = function () {
  8569. return "RadioButton";
  8570. };
  8571. RadioButton.prototype._draw = function (context) {
  8572. context.save();
  8573. this._applyStates(context);
  8574. var actualWidth = this._currentMeasure.width - this._thickness;
  8575. var actualHeight = this._currentMeasure.height - this._thickness;
  8576. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8577. context.shadowColor = this.shadowColor;
  8578. context.shadowBlur = this.shadowBlur;
  8579. context.shadowOffsetX = this.shadowOffsetX;
  8580. context.shadowOffsetY = this.shadowOffsetY;
  8581. }
  8582. // Outer
  8583. _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);
  8584. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8585. context.fill();
  8586. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8587. context.shadowBlur = 0;
  8588. context.shadowOffsetX = 0;
  8589. context.shadowOffsetY = 0;
  8590. }
  8591. context.strokeStyle = this.color;
  8592. context.lineWidth = this._thickness;
  8593. context.stroke();
  8594. // Inner
  8595. if (this._isChecked) {
  8596. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8597. var offsetWidth = actualWidth * this._checkSizeRatio;
  8598. var offseHeight = actualHeight * this._checkSizeRatio;
  8599. _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);
  8600. context.fill();
  8601. }
  8602. context.restore();
  8603. };
  8604. // Events
  8605. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8606. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8607. return false;
  8608. }
  8609. if (!this.isChecked) {
  8610. this.isChecked = true;
  8611. }
  8612. return true;
  8613. };
  8614. /**
  8615. * Utility function to easily create a radio button with a header
  8616. * @param title defines the label to use for the header
  8617. * @param group defines the group to use for the radio button
  8618. * @param isChecked defines the initial state of the radio button
  8619. * @param onValueChanged defines the callback to call when value changes
  8620. * @returns a StackPanel containing the radio button and a textBlock
  8621. */
  8622. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8623. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8624. panel.isVertical = false;
  8625. panel.height = "30px";
  8626. var radio = new RadioButton();
  8627. radio.width = "20px";
  8628. radio.height = "20px";
  8629. radio.isChecked = isChecked;
  8630. radio.color = "green";
  8631. radio.group = group;
  8632. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8633. panel.addControl(radio);
  8634. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8635. header.text = title;
  8636. header.width = "180px";
  8637. header.paddingLeft = "5px";
  8638. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8639. header.color = "white";
  8640. panel.addControl(header);
  8641. return panel;
  8642. };
  8643. return RadioButton;
  8644. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8645. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8646. /***/ }),
  8647. /***/ "./2D/controls/rectangle.ts":
  8648. /*!**********************************!*\
  8649. !*** ./2D/controls/rectangle.ts ***!
  8650. \**********************************/
  8651. /*! exports provided: Rectangle */
  8652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8653. "use strict";
  8654. __webpack_require__.r(__webpack_exports__);
  8655. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8656. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8657. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8658. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  8659. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8660. /** Class used to create rectangle container */
  8661. var Rectangle = /** @class */ (function (_super) {
  8662. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8663. /**
  8664. * Creates a new Rectangle
  8665. * @param name defines the control name
  8666. */
  8667. function Rectangle(name) {
  8668. var _this = _super.call(this, name) || this;
  8669. _this.name = name;
  8670. _this._thickness = 1;
  8671. _this._cornerRadius = 0;
  8672. return _this;
  8673. }
  8674. Object.defineProperty(Rectangle.prototype, "thickness", {
  8675. /** Gets or sets border thickness */
  8676. get: function () {
  8677. return this._thickness;
  8678. },
  8679. set: function (value) {
  8680. if (this._thickness === value) {
  8681. return;
  8682. }
  8683. this._thickness = value;
  8684. this._markAsDirty();
  8685. },
  8686. enumerable: true,
  8687. configurable: true
  8688. });
  8689. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8690. /** Gets or sets the corner radius angle */
  8691. get: function () {
  8692. return this._cornerRadius;
  8693. },
  8694. set: function (value) {
  8695. if (value < 0) {
  8696. value = 0;
  8697. }
  8698. if (this._cornerRadius === value) {
  8699. return;
  8700. }
  8701. this._cornerRadius = value;
  8702. this._markAsDirty();
  8703. },
  8704. enumerable: true,
  8705. configurable: true
  8706. });
  8707. Rectangle.prototype._getTypeName = function () {
  8708. return "Rectangle";
  8709. };
  8710. Rectangle.prototype._localDraw = function (context) {
  8711. context.save();
  8712. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8713. context.shadowColor = this.shadowColor;
  8714. context.shadowBlur = this.shadowBlur;
  8715. context.shadowOffsetX = this.shadowOffsetX;
  8716. context.shadowOffsetY = this.shadowOffsetY;
  8717. }
  8718. if (this._background) {
  8719. context.fillStyle = this._background;
  8720. if (this._cornerRadius) {
  8721. this._drawRoundedRect(context, this._thickness / 2);
  8722. context.fill();
  8723. }
  8724. else {
  8725. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8726. }
  8727. }
  8728. if (this._thickness) {
  8729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8730. context.shadowBlur = 0;
  8731. context.shadowOffsetX = 0;
  8732. context.shadowOffsetY = 0;
  8733. }
  8734. if (this.color) {
  8735. context.strokeStyle = this.color;
  8736. }
  8737. context.lineWidth = this._thickness;
  8738. if (this._cornerRadius) {
  8739. this._drawRoundedRect(context, this._thickness / 2);
  8740. context.stroke();
  8741. }
  8742. else {
  8743. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8744. }
  8745. }
  8746. context.restore();
  8747. };
  8748. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8749. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8750. this._measureForChildren.width -= 2 * this._thickness;
  8751. this._measureForChildren.height -= 2 * this._thickness;
  8752. this._measureForChildren.left += this._thickness;
  8753. this._measureForChildren.top += this._thickness;
  8754. };
  8755. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8756. if (offset === void 0) { offset = 0; }
  8757. var x = this._currentMeasure.left + offset;
  8758. var y = this._currentMeasure.top + offset;
  8759. var width = this._currentMeasure.width - offset * 2;
  8760. var height = this._currentMeasure.height - offset * 2;
  8761. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8762. context.beginPath();
  8763. context.moveTo(x + radius, y);
  8764. context.lineTo(x + width - radius, y);
  8765. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8766. context.lineTo(x + width, y + height - radius);
  8767. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8768. context.lineTo(x + radius, y + height);
  8769. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8770. context.lineTo(x, y + radius);
  8771. context.quadraticCurveTo(x, y, x + radius, y);
  8772. context.closePath();
  8773. };
  8774. Rectangle.prototype._clipForChildren = function (context) {
  8775. if (this._cornerRadius) {
  8776. this._drawRoundedRect(context, this._thickness);
  8777. context.clip();
  8778. }
  8779. };
  8780. return Rectangle;
  8781. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8782. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8783. /***/ }),
  8784. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8785. /*!***************************************************!*\
  8786. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8787. \***************************************************/
  8788. /*! exports provided: ScrollViewer */
  8789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8790. "use strict";
  8791. __webpack_require__.r(__webpack_exports__);
  8792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8793. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8794. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8795. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8796. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8797. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8798. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8799. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8800. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8801. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8802. /**
  8803. * Class used to hold a viewer window and sliders in a grid
  8804. */
  8805. var ScrollViewer = /** @class */ (function (_super) {
  8806. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8807. /**
  8808. * Creates a new ScrollViewer
  8809. * @param name of ScrollViewer
  8810. */
  8811. function ScrollViewer(name, isImageBased) {
  8812. var _this = _super.call(this, name) || this;
  8813. _this._barSize = 20;
  8814. _this._pointerIsOver = false;
  8815. _this._wheelPrecision = 0.05;
  8816. _this._thumbLength = 0.5;
  8817. _this._thumbHeight = 1;
  8818. _this._barImageHeight = 1;
  8819. _this._useImageBar = isImageBased ? isImageBased : false;
  8820. _this.onDirtyObservable.add(function () {
  8821. _this._horizontalBarSpace.color = _this.color;
  8822. _this._verticalBarSpace.color = _this.color;
  8823. _this._dragSpace.color = _this.color;
  8824. });
  8825. _this.onPointerEnterObservable.add(function () {
  8826. _this._pointerIsOver = true;
  8827. });
  8828. _this.onPointerOutObservable.add(function () {
  8829. _this._pointerIsOver = false;
  8830. });
  8831. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8832. if (_this._useImageBar) {
  8833. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8834. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8835. }
  8836. else {
  8837. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8838. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8839. }
  8840. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8841. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8842. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8843. _this._grid.addColumnDefinition(1);
  8844. _this._grid.addColumnDefinition(0, true);
  8845. _this._grid.addRowDefinition(1);
  8846. _this._grid.addRowDefinition(0, true);
  8847. _super.prototype.addControl.call(_this, _this._grid);
  8848. _this._grid.addControl(_this._window, 0, 0);
  8849. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8850. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8851. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8852. _this._verticalBarSpace.thickness = 1;
  8853. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8854. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  8855. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8856. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8857. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8858. _this._horizontalBarSpace.thickness = 1;
  8859. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8860. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  8861. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8862. _this._dragSpace.thickness = 1;
  8863. _this._grid.addControl(_this._dragSpace, 1, 1);
  8864. // Colors
  8865. if (!_this._useImageBar) {
  8866. _this.barColor = "grey";
  8867. _this.barBackground = "transparent";
  8868. }
  8869. return _this;
  8870. }
  8871. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8872. /**
  8873. * Gets the horizontal scrollbar
  8874. */
  8875. get: function () {
  8876. return this._horizontalBar;
  8877. },
  8878. enumerable: true,
  8879. configurable: true
  8880. });
  8881. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8882. /**
  8883. * Gets the vertical scrollbar
  8884. */
  8885. get: function () {
  8886. return this._verticalBar;
  8887. },
  8888. enumerable: true,
  8889. configurable: true
  8890. });
  8891. /**
  8892. * Adds a new control to the current container
  8893. * @param control defines the control to add
  8894. * @returns the current container
  8895. */
  8896. ScrollViewer.prototype.addControl = function (control) {
  8897. if (!control) {
  8898. return this;
  8899. }
  8900. this._window.addControl(control);
  8901. return this;
  8902. };
  8903. /**
  8904. * Removes a control from the current container
  8905. * @param control defines the control to remove
  8906. * @returns the current container
  8907. */
  8908. ScrollViewer.prototype.removeControl = function (control) {
  8909. this._window.removeControl(control);
  8910. return this;
  8911. };
  8912. Object.defineProperty(ScrollViewer.prototype, "children", {
  8913. /** Gets the list of children */
  8914. get: function () {
  8915. return this._window.children;
  8916. },
  8917. enumerable: true,
  8918. configurable: true
  8919. });
  8920. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8921. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8922. var child = _a[_i];
  8923. child._markMatrixAsDirty();
  8924. }
  8925. };
  8926. /** Reset the scroll viewer window to initial size */
  8927. ScrollViewer.prototype.resetWindow = function () {
  8928. this._window.width = "100%";
  8929. this._window.height = "100%";
  8930. };
  8931. ScrollViewer.prototype._getTypeName = function () {
  8932. return "ScrollViewer";
  8933. };
  8934. ScrollViewer.prototype._buildClientSizes = function () {
  8935. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8936. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8937. this._clientWidth = this._window.parentClientWidth;
  8938. this._clientHeight = this._window.parentClientHeight;
  8939. };
  8940. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8941. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8942. this._buildClientSizes();
  8943. };
  8944. ScrollViewer.prototype._postMeasure = function () {
  8945. _super.prototype._postMeasure.call(this);
  8946. this._updateScroller();
  8947. };
  8948. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8949. /**
  8950. * Gets or sets the mouse wheel precision
  8951. * from 0 to 1 with a default value of 0.05
  8952. * */
  8953. get: function () {
  8954. return this._wheelPrecision;
  8955. },
  8956. set: function (value) {
  8957. if (this._wheelPrecision === value) {
  8958. return;
  8959. }
  8960. if (value < 0) {
  8961. value = 0;
  8962. }
  8963. if (value > 1) {
  8964. value = 1;
  8965. }
  8966. this._wheelPrecision = value;
  8967. },
  8968. enumerable: true,
  8969. configurable: true
  8970. });
  8971. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  8972. /** Gets or sets the scroll bar container background color */
  8973. get: function () {
  8974. return this._horizontalBarSpace.background;
  8975. },
  8976. set: function (color) {
  8977. if (this._horizontalBarSpace.background === color) {
  8978. return;
  8979. }
  8980. this._horizontalBarSpace.background = color;
  8981. this._verticalBarSpace.background = color;
  8982. },
  8983. enumerable: true,
  8984. configurable: true
  8985. });
  8986. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8987. /** Gets or sets the bar color */
  8988. get: function () {
  8989. return this._barColor;
  8990. },
  8991. set: function (color) {
  8992. if (this._barColor === color) {
  8993. return;
  8994. }
  8995. this._barColor = color;
  8996. this._horizontalBar.color = color;
  8997. this._verticalBar.color = color;
  8998. },
  8999. enumerable: true,
  9000. configurable: true
  9001. });
  9002. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9003. /** Gets or sets the bar image */
  9004. get: function () {
  9005. return this._barImage;
  9006. },
  9007. set: function (value) {
  9008. if (this._barImage === value) {
  9009. return;
  9010. }
  9011. this._barImage = value;
  9012. var hb = this._horizontalBar;
  9013. var vb = this._verticalBar;
  9014. hb.thumbImage = value;
  9015. vb.thumbImage = value;
  9016. },
  9017. enumerable: true,
  9018. configurable: true
  9019. });
  9020. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9021. /** Gets or sets the size of the bar */
  9022. get: function () {
  9023. return this._barSize;
  9024. },
  9025. set: function (value) {
  9026. if (this._barSize === value) {
  9027. return;
  9028. }
  9029. this._barSize = value;
  9030. this._markAsDirty();
  9031. if (this._horizontalBar.isVisible) {
  9032. this._grid.setRowDefinition(1, this._barSize, true);
  9033. }
  9034. if (this._verticalBar.isVisible) {
  9035. this._grid.setColumnDefinition(1, this._barSize, true);
  9036. }
  9037. },
  9038. enumerable: true,
  9039. configurable: true
  9040. });
  9041. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9042. /** Gets or sets the length of the thumb */
  9043. get: function () {
  9044. return this._thumbLength;
  9045. },
  9046. set: function (value) {
  9047. if (this._thumbLength === value) {
  9048. return;
  9049. }
  9050. if (value <= 0) {
  9051. value = 0.1;
  9052. }
  9053. if (value > 1) {
  9054. value = 1;
  9055. }
  9056. this._thumbLength = value;
  9057. var hb = this._horizontalBar;
  9058. var vb = this._verticalBar;
  9059. hb.thumbLength = value;
  9060. vb.thumbLength = value;
  9061. this._markAsDirty();
  9062. },
  9063. enumerable: true,
  9064. configurable: true
  9065. });
  9066. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9067. /** Gets or sets the height of the thumb */
  9068. get: function () {
  9069. return this._thumbHeight;
  9070. },
  9071. set: function (value) {
  9072. if (this._thumbHeight === value) {
  9073. return;
  9074. }
  9075. if (value <= 0) {
  9076. value = 0.1;
  9077. }
  9078. if (value > 1) {
  9079. value = 1;
  9080. }
  9081. this._thumbHeight = value;
  9082. var hb = this._horizontalBar;
  9083. var vb = this._verticalBar;
  9084. hb.thumbHeight = value;
  9085. vb.thumbHeight = value;
  9086. this._markAsDirty();
  9087. },
  9088. enumerable: true,
  9089. configurable: true
  9090. });
  9091. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9092. /** Gets or sets the height of the bar image */
  9093. get: function () {
  9094. return this._barImageHeight;
  9095. },
  9096. set: function (value) {
  9097. if (this._barImageHeight === value) {
  9098. return;
  9099. }
  9100. if (value <= 0) {
  9101. value = 0.1;
  9102. }
  9103. if (value > 1) {
  9104. value = 1;
  9105. }
  9106. this._barImageHeight = value;
  9107. var hb = this._horizontalBar;
  9108. var vb = this._verticalBar;
  9109. hb.barImageHeight = value;
  9110. vb.barImageHeight = value;
  9111. this._markAsDirty();
  9112. },
  9113. enumerable: true,
  9114. configurable: true
  9115. });
  9116. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9117. /** Gets or sets the bar background */
  9118. get: function () {
  9119. return this._barBackground;
  9120. },
  9121. set: function (color) {
  9122. if (this._barBackground === color) {
  9123. return;
  9124. }
  9125. this._barBackground = color;
  9126. var hb = this._horizontalBar;
  9127. var vb = this._verticalBar;
  9128. hb.background = color;
  9129. vb.background = color;
  9130. this._dragSpace.background = color;
  9131. },
  9132. enumerable: true,
  9133. configurable: true
  9134. });
  9135. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9136. /** Gets or sets the bar background image */
  9137. get: function () {
  9138. return this._barBackgroundImage;
  9139. },
  9140. set: function (value) {
  9141. if (this._barBackgroundImage === value) {
  9142. }
  9143. this._barBackgroundImage = value;
  9144. var hb = this._horizontalBar;
  9145. var vb = this._verticalBar;
  9146. hb.backgroundImage = value;
  9147. vb.backgroundImage = value;
  9148. },
  9149. enumerable: true,
  9150. configurable: true
  9151. });
  9152. /** @hidden */
  9153. ScrollViewer.prototype._updateScroller = function () {
  9154. var windowContentsWidth = this._window._currentMeasure.width;
  9155. var windowContentsHeight = this._window._currentMeasure.height;
  9156. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9157. this._grid.setRowDefinition(1, 0, true);
  9158. this._horizontalBar.isVisible = false;
  9159. this._horizontalBar.value = 0;
  9160. this._rebuildLayout = true;
  9161. }
  9162. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9163. this._grid.setRowDefinition(1, this._barSize, true);
  9164. this._horizontalBar.isVisible = true;
  9165. this._rebuildLayout = true;
  9166. }
  9167. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9168. this._grid.setColumnDefinition(1, 0, true);
  9169. this._verticalBar.isVisible = false;
  9170. this._verticalBar.value = 0;
  9171. this._rebuildLayout = true;
  9172. }
  9173. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9174. this._grid.setColumnDefinition(1, this._barSize, true);
  9175. this._verticalBar.isVisible = true;
  9176. this._rebuildLayout = true;
  9177. }
  9178. this._buildClientSizes();
  9179. this._endLeft = this._clientWidth - windowContentsWidth;
  9180. this._endTop = this._clientHeight - windowContentsHeight;
  9181. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9182. var newTop = this._verticalBar.value * this._endTop + "px";
  9183. if (newLeft !== this._window.left) {
  9184. this._window.left = newLeft;
  9185. this._rebuildLayout = true;
  9186. }
  9187. if (newTop !== this._window.top) {
  9188. this._window.top = newTop;
  9189. this._rebuildLayout = true;
  9190. }
  9191. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * this._clientWidth + "px";
  9192. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * this._clientHeight + "px";
  9193. };
  9194. ScrollViewer.prototype._link = function (host) {
  9195. _super.prototype._link.call(this, host);
  9196. this._attachWheel();
  9197. };
  9198. /** @hidden */
  9199. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9200. var _this = this;
  9201. barControl.paddingLeft = 0;
  9202. barControl.width = "100%";
  9203. barControl.height = "100%";
  9204. barControl.barOffset = 0;
  9205. barControl.value = 0;
  9206. barControl.maximum = 1;
  9207. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9208. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9209. barControl.isVertical = isVertical;
  9210. barControl.rotation = rotation;
  9211. barControl.isVisible = false;
  9212. barContainer.addControl(barControl);
  9213. barControl.onValueChangedObservable.add(function (value) {
  9214. if (rotation > 0) {
  9215. _this._window.top = value * _this._endTop + "px";
  9216. }
  9217. else {
  9218. _this._window.left = value * _this._endLeft + "px";
  9219. }
  9220. });
  9221. };
  9222. /** @hidden */
  9223. ScrollViewer.prototype._attachWheel = function () {
  9224. var _this = this;
  9225. if (!this._host || this._onPointerObserver) {
  9226. return;
  9227. }
  9228. var scene = this._host.getScene();
  9229. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9230. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9231. return;
  9232. }
  9233. if (_this._verticalBar.isVisible == true) {
  9234. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9235. _this._verticalBar.value -= _this._wheelPrecision;
  9236. }
  9237. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9238. _this._verticalBar.value += _this._wheelPrecision;
  9239. }
  9240. }
  9241. if (_this._horizontalBar.isVisible == true) {
  9242. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9243. _this._horizontalBar.value += _this._wheelPrecision;
  9244. }
  9245. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9246. _this._horizontalBar.value -= _this._wheelPrecision;
  9247. }
  9248. }
  9249. });
  9250. };
  9251. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9252. if (!this.isHighlighted) {
  9253. return;
  9254. }
  9255. _super.prototype._renderHighlightSpecific.call(this, context);
  9256. this._grid._renderHighlightSpecific(context);
  9257. context.restore();
  9258. };
  9259. /** Releases associated resources */
  9260. ScrollViewer.prototype.dispose = function () {
  9261. var scene = this._host.getScene();
  9262. if (scene && this._onPointerObserver) {
  9263. scene.onPointerObservable.remove(this._onPointerObserver);
  9264. this._onPointerObserver = null;
  9265. }
  9266. _super.prototype.dispose.call(this);
  9267. };
  9268. return ScrollViewer;
  9269. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9270. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9271. /***/ }),
  9272. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9273. /*!*********************************************************!*\
  9274. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9275. \*********************************************************/
  9276. /*! exports provided: _ScrollViewerWindow */
  9277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9278. "use strict";
  9279. __webpack_require__.r(__webpack_exports__);
  9280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9281. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9282. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9283. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9284. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9285. /**
  9286. * Class used to hold a the container for ScrollViewer
  9287. * @hidden
  9288. */
  9289. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9290. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9291. /**
  9292. * Creates a new ScrollViewerWindow
  9293. * @param name of ScrollViewerWindow
  9294. */
  9295. function _ScrollViewerWindow(name) {
  9296. return _super.call(this, name) || this;
  9297. }
  9298. _ScrollViewerWindow.prototype._getTypeName = function () {
  9299. return "ScrollViewerWindow";
  9300. };
  9301. /** @hidden */
  9302. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9303. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9304. this._measureForChildren.left = this._currentMeasure.left;
  9305. this._measureForChildren.top = this._currentMeasure.top;
  9306. this._measureForChildren.width = parentMeasure.width;
  9307. this._measureForChildren.height = parentMeasure.height;
  9308. };
  9309. _ScrollViewerWindow.prototype._postMeasure = function () {
  9310. var maxWidth = this.parentClientWidth;
  9311. var maxHeight = this.parentClientHeight;
  9312. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9313. var child = _a[_i];
  9314. if (!child.isVisible || child.notRenderable) {
  9315. continue;
  9316. }
  9317. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9318. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9319. }
  9320. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9321. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9322. }
  9323. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9324. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9325. }
  9326. if (this._currentMeasure.width !== maxWidth) {
  9327. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9328. this._currentMeasure.width = maxWidth;
  9329. this._rebuildLayout = true;
  9330. this._isDirty = true;
  9331. }
  9332. if (this._currentMeasure.height !== maxHeight) {
  9333. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9334. this._currentMeasure.height = maxHeight;
  9335. this._rebuildLayout = true;
  9336. this._isDirty = true;
  9337. }
  9338. _super.prototype._postMeasure.call(this);
  9339. };
  9340. return _ScrollViewerWindow;
  9341. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9342. /***/ }),
  9343. /***/ "./2D/controls/selector.ts":
  9344. /*!*********************************!*\
  9345. !*** ./2D/controls/selector.ts ***!
  9346. \*********************************/
  9347. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9348. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9349. "use strict";
  9350. __webpack_require__.r(__webpack_exports__);
  9351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9356. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9357. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9358. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9359. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9360. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9361. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9362. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9363. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9364. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9365. /** Class used to create a RadioGroup
  9366. * which contains groups of radio buttons
  9367. */
  9368. var SelectorGroup = /** @class */ (function () {
  9369. /**
  9370. * Creates a new SelectorGroup
  9371. * @param name of group, used as a group heading
  9372. */
  9373. function SelectorGroup(
  9374. /** name of SelectorGroup */
  9375. name) {
  9376. this.name = name;
  9377. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9378. this._selectors = new Array();
  9379. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9380. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9381. this._groupHeader = this._addGroupHeader(name);
  9382. }
  9383. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9384. /** Gets the groupPanel of the SelectorGroup */
  9385. get: function () {
  9386. return this._groupPanel;
  9387. },
  9388. enumerable: true,
  9389. configurable: true
  9390. });
  9391. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9392. /** Gets the selectors array */
  9393. get: function () {
  9394. return this._selectors;
  9395. },
  9396. enumerable: true,
  9397. configurable: true
  9398. });
  9399. Object.defineProperty(SelectorGroup.prototype, "header", {
  9400. /** Gets and sets the group header */
  9401. get: function () {
  9402. return this._groupHeader.text;
  9403. },
  9404. set: function (label) {
  9405. if (this._groupHeader.text === "label") {
  9406. return;
  9407. }
  9408. this._groupHeader.text = label;
  9409. },
  9410. enumerable: true,
  9411. configurable: true
  9412. });
  9413. /** @hidden */
  9414. SelectorGroup.prototype._addGroupHeader = function (text) {
  9415. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9416. groupHeading.width = 0.9;
  9417. groupHeading.height = "30px";
  9418. groupHeading.textWrapping = true;
  9419. groupHeading.color = "black";
  9420. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9421. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9422. groupHeading.left = "2px";
  9423. this._groupPanel.addControl(groupHeading);
  9424. return groupHeading;
  9425. };
  9426. /** @hidden*/
  9427. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9428. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9429. return;
  9430. }
  9431. return this._selectors[selectorNb];
  9432. };
  9433. /** Removes the selector at the given position
  9434. * @param selectorNb the position of the selector within the group
  9435. */
  9436. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9437. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9438. return;
  9439. }
  9440. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9441. this._selectors.splice(selectorNb, 1);
  9442. };
  9443. return SelectorGroup;
  9444. }());
  9445. /** Class used to create a CheckboxGroup
  9446. * which contains groups of checkbox buttons
  9447. */
  9448. var CheckboxGroup = /** @class */ (function (_super) {
  9449. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9450. function CheckboxGroup() {
  9451. return _super !== null && _super.apply(this, arguments) || this;
  9452. }
  9453. /** Adds a checkbox as a control
  9454. * @param text is the label for the selector
  9455. * @param func is the function called when the Selector is checked
  9456. * @param checked is true when Selector is checked
  9457. */
  9458. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9459. if (func === void 0) { func = function (s) { }; }
  9460. if (checked === void 0) { checked = false; }
  9461. var checked = checked || false;
  9462. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9463. button.width = "20px";
  9464. button.height = "20px";
  9465. button.color = "#364249";
  9466. button.background = "#CCCCCC";
  9467. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9468. button.onIsCheckedChangedObservable.add(function (state) {
  9469. func(state);
  9470. });
  9471. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9472. _selector.height = "30px";
  9473. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9474. _selector.left = "4px";
  9475. this.groupPanel.addControl(_selector);
  9476. this.selectors.push(_selector);
  9477. button.isChecked = checked;
  9478. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9479. button.color = this.groupPanel.parent.parent.buttonColor;
  9480. button.background = this.groupPanel.parent.parent.buttonBackground;
  9481. }
  9482. };
  9483. /** @hidden */
  9484. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9485. this.selectors[selectorNb].children[1].text = label;
  9486. };
  9487. /** @hidden */
  9488. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9489. this.selectors[selectorNb].children[1].color = color;
  9490. };
  9491. /** @hidden */
  9492. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9493. this.selectors[selectorNb].children[0].color = color;
  9494. };
  9495. /** @hidden */
  9496. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9497. this.selectors[selectorNb].children[0].background = color;
  9498. };
  9499. return CheckboxGroup;
  9500. }(SelectorGroup));
  9501. /** Class used to create a RadioGroup
  9502. * which contains groups of radio buttons
  9503. */
  9504. var RadioGroup = /** @class */ (function (_super) {
  9505. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9506. function RadioGroup() {
  9507. var _this = _super !== null && _super.apply(this, arguments) || this;
  9508. _this._selectNb = 0;
  9509. return _this;
  9510. }
  9511. /** Adds a radio button as a control
  9512. * @param label is the label for the selector
  9513. * @param func is the function called when the Selector is checked
  9514. * @param checked is true when Selector is checked
  9515. */
  9516. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9517. if (func === void 0) { func = function (n) { }; }
  9518. if (checked === void 0) { checked = false; }
  9519. var nb = this._selectNb++;
  9520. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9521. button.name = label;
  9522. button.width = "20px";
  9523. button.height = "20px";
  9524. button.color = "#364249";
  9525. button.background = "#CCCCCC";
  9526. button.group = this.name;
  9527. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9528. button.onIsCheckedChangedObservable.add(function (state) {
  9529. if (state) {
  9530. func(nb);
  9531. }
  9532. });
  9533. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9534. _selector.height = "30px";
  9535. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9536. _selector.left = "4px";
  9537. this.groupPanel.addControl(_selector);
  9538. this.selectors.push(_selector);
  9539. button.isChecked = checked;
  9540. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9541. button.color = this.groupPanel.parent.parent.buttonColor;
  9542. button.background = this.groupPanel.parent.parent.buttonBackground;
  9543. }
  9544. };
  9545. /** @hidden */
  9546. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9547. this.selectors[selectorNb].children[1].text = label;
  9548. };
  9549. /** @hidden */
  9550. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9551. this.selectors[selectorNb].children[1].color = color;
  9552. };
  9553. /** @hidden */
  9554. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9555. this.selectors[selectorNb].children[0].color = color;
  9556. };
  9557. /** @hidden */
  9558. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9559. this.selectors[selectorNb].children[0].background = color;
  9560. };
  9561. return RadioGroup;
  9562. }(SelectorGroup));
  9563. /** Class used to create a SliderGroup
  9564. * which contains groups of slider buttons
  9565. */
  9566. var SliderGroup = /** @class */ (function (_super) {
  9567. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  9568. function SliderGroup() {
  9569. return _super !== null && _super.apply(this, arguments) || this;
  9570. }
  9571. /**
  9572. * Adds a slider to the SelectorGroup
  9573. * @param label is the label for the SliderBar
  9574. * @param func is the function called when the Slider moves
  9575. * @param unit is a string describing the units used, eg degrees or metres
  9576. * @param min is the minimum value for the Slider
  9577. * @param max is the maximum value for the Slider
  9578. * @param value is the start value for the Slider between min and max
  9579. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9580. */
  9581. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9582. if (func === void 0) { func = function (v) { }; }
  9583. if (unit === void 0) { unit = "Units"; }
  9584. if (min === void 0) { min = 0; }
  9585. if (max === void 0) { max = 0; }
  9586. if (value === void 0) { value = 0; }
  9587. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9588. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9589. button.name = unit;
  9590. button.value = value;
  9591. button.minimum = min;
  9592. button.maximum = max;
  9593. button.width = 0.9;
  9594. button.height = "20px";
  9595. button.color = "#364249";
  9596. button.background = "#CCCCCC";
  9597. button.borderColor = "black";
  9598. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9599. button.left = "4px";
  9600. button.paddingBottom = "4px";
  9601. button.onValueChangedObservable.add(function (value) {
  9602. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9603. func(value);
  9604. });
  9605. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9606. _selector.height = "60px";
  9607. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9608. _selector.left = "4px";
  9609. _selector.children[0].name = label;
  9610. this.groupPanel.addControl(_selector);
  9611. this.selectors.push(_selector);
  9612. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9613. button.color = this.groupPanel.parent.parent.buttonColor;
  9614. button.background = this.groupPanel.parent.parent.buttonBackground;
  9615. }
  9616. };
  9617. /** @hidden */
  9618. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9619. this.selectors[selectorNb].children[0].name = label;
  9620. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9621. };
  9622. /** @hidden */
  9623. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9624. this.selectors[selectorNb].children[0].color = color;
  9625. };
  9626. /** @hidden */
  9627. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9628. this.selectors[selectorNb].children[1].color = color;
  9629. };
  9630. /** @hidden */
  9631. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9632. this.selectors[selectorNb].children[1].background = color;
  9633. };
  9634. return SliderGroup;
  9635. }(SelectorGroup));
  9636. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9637. * @see http://doc.babylonjs.com/how_to/selector
  9638. */
  9639. var SelectionPanel = /** @class */ (function (_super) {
  9640. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  9641. /**
  9642. * Creates a new SelectionPanel
  9643. * @param name of SelectionPanel
  9644. * @param groups is an array of SelectionGroups
  9645. */
  9646. function SelectionPanel(
  9647. /** name of SelectionPanel */
  9648. name,
  9649. /** an array of SelectionGroups */
  9650. groups) {
  9651. if (groups === void 0) { groups = []; }
  9652. var _this = _super.call(this, name) || this;
  9653. _this.name = name;
  9654. _this.groups = groups;
  9655. _this._buttonColor = "#364249";
  9656. _this._buttonBackground = "#CCCCCC";
  9657. _this._headerColor = "black";
  9658. _this._barColor = "white";
  9659. _this._barHeight = "2px";
  9660. _this._spacerHeight = "20px";
  9661. _this._bars = new Array();
  9662. _this._groups = groups;
  9663. _this.thickness = 2;
  9664. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9665. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9666. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9667. _this._panel.top = 5;
  9668. _this._panel.left = 5;
  9669. _this._panel.width = 0.95;
  9670. if (groups.length > 0) {
  9671. for (var i = 0; i < groups.length - 1; i++) {
  9672. _this._panel.addControl(groups[i].groupPanel);
  9673. _this._addSpacer();
  9674. }
  9675. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9676. }
  9677. _this.addControl(_this._panel);
  9678. return _this;
  9679. }
  9680. SelectionPanel.prototype._getTypeName = function () {
  9681. return "SelectionPanel";
  9682. };
  9683. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9684. /** Gets or sets the headerColor */
  9685. get: function () {
  9686. return this._headerColor;
  9687. },
  9688. set: function (color) {
  9689. if (this._headerColor === color) {
  9690. return;
  9691. }
  9692. this._headerColor = color;
  9693. this._setHeaderColor();
  9694. },
  9695. enumerable: true,
  9696. configurable: true
  9697. });
  9698. SelectionPanel.prototype._setHeaderColor = function () {
  9699. for (var i = 0; i < this._groups.length; i++) {
  9700. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9701. }
  9702. };
  9703. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9704. /** Gets or sets the button color */
  9705. get: function () {
  9706. return this._buttonColor;
  9707. },
  9708. set: function (color) {
  9709. if (this._buttonColor === color) {
  9710. return;
  9711. }
  9712. this._buttonColor = color;
  9713. this._setbuttonColor();
  9714. },
  9715. enumerable: true,
  9716. configurable: true
  9717. });
  9718. SelectionPanel.prototype._setbuttonColor = function () {
  9719. for (var i = 0; i < this._groups.length; i++) {
  9720. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9721. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9722. }
  9723. }
  9724. };
  9725. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9726. /** Gets or sets the label color */
  9727. get: function () {
  9728. return this._labelColor;
  9729. },
  9730. set: function (color) {
  9731. if (this._labelColor === color) {
  9732. return;
  9733. }
  9734. this._labelColor = color;
  9735. this._setLabelColor();
  9736. },
  9737. enumerable: true,
  9738. configurable: true
  9739. });
  9740. SelectionPanel.prototype._setLabelColor = function () {
  9741. for (var i = 0; i < this._groups.length; i++) {
  9742. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9743. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9744. }
  9745. }
  9746. };
  9747. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9748. /** Gets or sets the button background */
  9749. get: function () {
  9750. return this._buttonBackground;
  9751. },
  9752. set: function (color) {
  9753. if (this._buttonBackground === color) {
  9754. return;
  9755. }
  9756. this._buttonBackground = color;
  9757. this._setButtonBackground();
  9758. },
  9759. enumerable: true,
  9760. configurable: true
  9761. });
  9762. SelectionPanel.prototype._setButtonBackground = function () {
  9763. for (var i = 0; i < this._groups.length; i++) {
  9764. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9765. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9766. }
  9767. }
  9768. };
  9769. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9770. /** Gets or sets the color of separator bar */
  9771. get: function () {
  9772. return this._barColor;
  9773. },
  9774. set: function (color) {
  9775. if (this._barColor === color) {
  9776. return;
  9777. }
  9778. this._barColor = color;
  9779. this._setBarColor();
  9780. },
  9781. enumerable: true,
  9782. configurable: true
  9783. });
  9784. SelectionPanel.prototype._setBarColor = function () {
  9785. for (var i = 0; i < this._bars.length; i++) {
  9786. this._bars[i].children[0].background = this._barColor;
  9787. }
  9788. };
  9789. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9790. /** Gets or sets the height of separator bar */
  9791. get: function () {
  9792. return this._barHeight;
  9793. },
  9794. set: function (value) {
  9795. if (this._barHeight === value) {
  9796. return;
  9797. }
  9798. this._barHeight = value;
  9799. this._setBarHeight();
  9800. },
  9801. enumerable: true,
  9802. configurable: true
  9803. });
  9804. SelectionPanel.prototype._setBarHeight = function () {
  9805. for (var i = 0; i < this._bars.length; i++) {
  9806. this._bars[i].children[0].height = this._barHeight;
  9807. }
  9808. };
  9809. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9810. /** Gets or sets the height of spacers*/
  9811. get: function () {
  9812. return this._spacerHeight;
  9813. },
  9814. set: function (value) {
  9815. if (this._spacerHeight === value) {
  9816. return;
  9817. }
  9818. this._spacerHeight = value;
  9819. this._setSpacerHeight();
  9820. },
  9821. enumerable: true,
  9822. configurable: true
  9823. });
  9824. SelectionPanel.prototype._setSpacerHeight = function () {
  9825. for (var i = 0; i < this._bars.length; i++) {
  9826. this._bars[i].height = this._spacerHeight;
  9827. }
  9828. };
  9829. /** Adds a bar between groups */
  9830. SelectionPanel.prototype._addSpacer = function () {
  9831. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9832. separator.width = 1;
  9833. separator.height = this._spacerHeight;
  9834. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9835. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9836. bar.width = 1;
  9837. bar.height = this._barHeight;
  9838. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9839. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9840. bar.background = this._barColor;
  9841. bar.color = "transparent";
  9842. separator.addControl(bar);
  9843. this._panel.addControl(separator);
  9844. this._bars.push(separator);
  9845. };
  9846. /** Add a group to the selection panel
  9847. * @param group is the selector group to add
  9848. */
  9849. SelectionPanel.prototype.addGroup = function (group) {
  9850. if (this._groups.length > 0) {
  9851. this._addSpacer();
  9852. }
  9853. this._panel.addControl(group.groupPanel);
  9854. this._groups.push(group);
  9855. group.groupPanel.children[0].color = this._headerColor;
  9856. for (var j = 0; j < group.selectors.length; j++) {
  9857. group._setSelectorButtonColor(j, this._buttonColor);
  9858. group._setSelectorButtonBackground(j, this._buttonBackground);
  9859. }
  9860. };
  9861. /** Remove the group from the given position
  9862. * @param groupNb is the position of the group in the list
  9863. */
  9864. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9865. if (groupNb < 0 || groupNb >= this._groups.length) {
  9866. return;
  9867. }
  9868. var group = this._groups[groupNb];
  9869. this._panel.removeControl(group.groupPanel);
  9870. this._groups.splice(groupNb, 1);
  9871. if (groupNb < this._bars.length) {
  9872. this._panel.removeControl(this._bars[groupNb]);
  9873. this._bars.splice(groupNb, 1);
  9874. }
  9875. };
  9876. /** Change a group header label
  9877. * @param label is the new group header label
  9878. * @param groupNb is the number of the group to relabel
  9879. * */
  9880. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9881. if (groupNb < 0 || groupNb >= this._groups.length) {
  9882. return;
  9883. }
  9884. var group = this._groups[groupNb];
  9885. group.groupPanel.children[0].text = label;
  9886. };
  9887. /** Change selector label to the one given
  9888. * @param label is the new selector label
  9889. * @param groupNb is the number of the groupcontaining the selector
  9890. * @param selectorNb is the number of the selector within a group to relabel
  9891. * */
  9892. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9893. if (groupNb < 0 || groupNb >= this._groups.length) {
  9894. return;
  9895. }
  9896. var group = this._groups[groupNb];
  9897. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9898. return;
  9899. }
  9900. group._setSelectorLabel(selectorNb, label);
  9901. };
  9902. /** For a given group position remove the selector at the given position
  9903. * @param groupNb is the number of the group to remove the selector from
  9904. * @param selectorNb is the number of the selector within the group
  9905. */
  9906. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9907. if (groupNb < 0 || groupNb >= this._groups.length) {
  9908. return;
  9909. }
  9910. var group = this._groups[groupNb];
  9911. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9912. return;
  9913. }
  9914. group.removeSelector(selectorNb);
  9915. };
  9916. /** For a given group position of correct type add a checkbox button
  9917. * @param groupNb is the number of the group to remove the selector from
  9918. * @param label is the label for the selector
  9919. * @param func is the function called when the Selector is checked
  9920. * @param checked is true when Selector is checked
  9921. */
  9922. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9923. if (func === void 0) { func = function () { }; }
  9924. if (checked === void 0) { checked = false; }
  9925. if (groupNb < 0 || groupNb >= this._groups.length) {
  9926. return;
  9927. }
  9928. var group = this._groups[groupNb];
  9929. group.addCheckbox(label, func, checked);
  9930. };
  9931. /** For a given group position of correct type add a radio button
  9932. * @param groupNb is the number of the group to remove the selector from
  9933. * @param label is the label for the selector
  9934. * @param func is the function called when the Selector is checked
  9935. * @param checked is true when Selector is checked
  9936. */
  9937. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9938. if (func === void 0) { func = function () { }; }
  9939. if (checked === void 0) { checked = false; }
  9940. if (groupNb < 0 || groupNb >= this._groups.length) {
  9941. return;
  9942. }
  9943. var group = this._groups[groupNb];
  9944. group.addRadio(label, func, checked);
  9945. };
  9946. /**
  9947. * For a given slider group add a slider
  9948. * @param groupNb is the number of the group to add the slider to
  9949. * @param label is the label for the Slider
  9950. * @param func is the function called when the Slider moves
  9951. * @param unit is a string describing the units used, eg degrees or metres
  9952. * @param min is the minimum value for the Slider
  9953. * @param max is the maximum value for the Slider
  9954. * @param value is the start value for the Slider between min and max
  9955. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9956. */
  9957. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9958. if (func === void 0) { func = function () { }; }
  9959. if (unit === void 0) { unit = "Units"; }
  9960. if (min === void 0) { min = 0; }
  9961. if (max === void 0) { max = 0; }
  9962. if (value === void 0) { value = 0; }
  9963. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9964. if (groupNb < 0 || groupNb >= this._groups.length) {
  9965. return;
  9966. }
  9967. var group = this._groups[groupNb];
  9968. group.addSlider(label, func, unit, min, max, value, onVal);
  9969. };
  9970. return SelectionPanel;
  9971. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9972. /***/ }),
  9973. /***/ "./2D/controls/sliders/baseSlider.ts":
  9974. /*!*******************************************!*\
  9975. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9976. \*******************************************/
  9977. /*! exports provided: BaseSlider */
  9978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9979. "use strict";
  9980. __webpack_require__.r(__webpack_exports__);
  9981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9982. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9983. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  9984. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9985. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9986. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9987. /**
  9988. * Class used to create slider controls
  9989. */
  9990. var BaseSlider = /** @class */ (function (_super) {
  9991. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  9992. /**
  9993. * Creates a new BaseSlider
  9994. * @param name defines the control name
  9995. */
  9996. function BaseSlider(name) {
  9997. var _this = _super.call(this, name) || this;
  9998. _this.name = name;
  9999. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10000. _this._minimum = 0;
  10001. _this._maximum = 100;
  10002. _this._value = 50;
  10003. _this._isVertical = false;
  10004. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10005. _this._isThumbClamped = false;
  10006. _this._displayThumb = true;
  10007. _this._step = 0;
  10008. _this._lastPointerDownID = -1;
  10009. // Shared rendering info
  10010. _this._effectiveBarOffset = 0;
  10011. /** Observable raised when the sldier value changes */
  10012. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10013. // Events
  10014. _this._pointerIsDown = false;
  10015. _this.isPointerBlocker = true;
  10016. return _this;
  10017. }
  10018. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10019. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10020. get: function () {
  10021. return this._displayThumb;
  10022. },
  10023. set: function (value) {
  10024. if (this._displayThumb === value) {
  10025. return;
  10026. }
  10027. this._displayThumb = value;
  10028. this._markAsDirty();
  10029. },
  10030. enumerable: true,
  10031. configurable: true
  10032. });
  10033. Object.defineProperty(BaseSlider.prototype, "step", {
  10034. /** Gets or sets a step to apply to values (0 by default) */
  10035. get: function () {
  10036. return this._step;
  10037. },
  10038. set: function (value) {
  10039. if (this._step === value) {
  10040. return;
  10041. }
  10042. this._step = value;
  10043. this._markAsDirty();
  10044. },
  10045. enumerable: true,
  10046. configurable: true
  10047. });
  10048. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10049. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10050. get: function () {
  10051. return this._barOffset.toString(this._host);
  10052. },
  10053. set: function (value) {
  10054. if (this._barOffset.toString(this._host) === value) {
  10055. return;
  10056. }
  10057. if (this._barOffset.fromString(value)) {
  10058. this._markAsDirty();
  10059. }
  10060. },
  10061. enumerable: true,
  10062. configurable: true
  10063. });
  10064. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10065. /** Gets main bar offset in pixels*/
  10066. get: function () {
  10067. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10068. },
  10069. enumerable: true,
  10070. configurable: true
  10071. });
  10072. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10073. /** Gets or sets thumb width */
  10074. get: function () {
  10075. return this._thumbWidth.toString(this._host);
  10076. },
  10077. set: function (value) {
  10078. if (this._thumbWidth.toString(this._host) === value) {
  10079. return;
  10080. }
  10081. if (this._thumbWidth.fromString(value)) {
  10082. this._markAsDirty();
  10083. }
  10084. },
  10085. enumerable: true,
  10086. configurable: true
  10087. });
  10088. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10089. /** Gets thumb width in pixels */
  10090. get: function () {
  10091. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10092. },
  10093. enumerable: true,
  10094. configurable: true
  10095. });
  10096. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10097. /** Gets or sets minimum value */
  10098. get: function () {
  10099. return this._minimum;
  10100. },
  10101. set: function (value) {
  10102. if (this._minimum === value) {
  10103. return;
  10104. }
  10105. this._minimum = value;
  10106. this._markAsDirty();
  10107. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10108. },
  10109. enumerable: true,
  10110. configurable: true
  10111. });
  10112. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10113. /** Gets or sets maximum value */
  10114. get: function () {
  10115. return this._maximum;
  10116. },
  10117. set: function (value) {
  10118. if (this._maximum === value) {
  10119. return;
  10120. }
  10121. this._maximum = value;
  10122. this._markAsDirty();
  10123. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10124. },
  10125. enumerable: true,
  10126. configurable: true
  10127. });
  10128. Object.defineProperty(BaseSlider.prototype, "value", {
  10129. /** Gets or sets current value */
  10130. get: function () {
  10131. return this._value;
  10132. },
  10133. set: function (value) {
  10134. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10135. if (this._value === value) {
  10136. return;
  10137. }
  10138. this._value = value;
  10139. this._markAsDirty();
  10140. this.onValueChangedObservable.notifyObservers(this._value);
  10141. },
  10142. enumerable: true,
  10143. configurable: true
  10144. });
  10145. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10146. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10147. get: function () {
  10148. return this._isVertical;
  10149. },
  10150. set: function (value) {
  10151. if (this._isVertical === value) {
  10152. return;
  10153. }
  10154. this._isVertical = value;
  10155. this._markAsDirty();
  10156. },
  10157. enumerable: true,
  10158. configurable: true
  10159. });
  10160. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10161. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10162. get: function () {
  10163. return this._isThumbClamped;
  10164. },
  10165. set: function (value) {
  10166. if (this._isThumbClamped === value) {
  10167. return;
  10168. }
  10169. this._isThumbClamped = value;
  10170. this._markAsDirty();
  10171. },
  10172. enumerable: true,
  10173. configurable: true
  10174. });
  10175. BaseSlider.prototype._getTypeName = function () {
  10176. return "BaseSlider";
  10177. };
  10178. BaseSlider.prototype._getThumbPosition = function () {
  10179. if (this.isVertical) {
  10180. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10181. }
  10182. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10183. };
  10184. BaseSlider.prototype._getThumbThickness = function (type) {
  10185. var thumbThickness = 0;
  10186. switch (type) {
  10187. case "circle":
  10188. if (this._thumbWidth.isPixel) {
  10189. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10190. }
  10191. else {
  10192. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10193. }
  10194. break;
  10195. case "rectangle":
  10196. if (this._thumbWidth.isPixel) {
  10197. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10198. }
  10199. else {
  10200. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10201. }
  10202. }
  10203. return thumbThickness;
  10204. };
  10205. BaseSlider.prototype._prepareRenderingData = function (type) {
  10206. // Main bar
  10207. this._effectiveBarOffset = 0;
  10208. this._renderLeft = this._currentMeasure.left;
  10209. this._renderTop = this._currentMeasure.top;
  10210. this._renderWidth = this._currentMeasure.width;
  10211. this._renderHeight = this._currentMeasure.height;
  10212. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10213. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10214. this._effectiveThumbThickness = this._getThumbThickness(type);
  10215. if (this.displayThumb) {
  10216. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10217. }
  10218. //throw error when height is less than width for vertical slider
  10219. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10220. console.error("Height should be greater than width");
  10221. return;
  10222. }
  10223. if (this._barOffset.isPixel) {
  10224. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10225. }
  10226. else {
  10227. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10228. }
  10229. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10230. if (this.isVertical) {
  10231. this._renderLeft += this._effectiveBarOffset;
  10232. if (!this.isThumbClamped && this.displayThumb) {
  10233. this._renderTop += (this._effectiveThumbThickness / 2);
  10234. }
  10235. this._renderHeight = this._backgroundBoxLength;
  10236. this._renderWidth = this._backgroundBoxThickness;
  10237. }
  10238. else {
  10239. this._renderTop += this._effectiveBarOffset;
  10240. if (!this.isThumbClamped && this.displayThumb) {
  10241. this._renderLeft += (this._effectiveThumbThickness / 2);
  10242. }
  10243. this._renderHeight = this._backgroundBoxThickness;
  10244. this._renderWidth = this._backgroundBoxLength;
  10245. }
  10246. };
  10247. /** @hidden */
  10248. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10249. if (this.rotation != 0) {
  10250. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10251. x = this._transformedPosition.x;
  10252. y = this._transformedPosition.y;
  10253. }
  10254. var value;
  10255. if (this._isVertical) {
  10256. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10257. }
  10258. else {
  10259. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10260. }
  10261. var mult = (1 / this._step) | 0;
  10262. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10263. };
  10264. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10265. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10266. return false;
  10267. }
  10268. this._pointerIsDown = true;
  10269. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10270. this._host._capturingControl[pointerId] = this;
  10271. this._lastPointerDownID = pointerId;
  10272. return true;
  10273. };
  10274. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10275. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10276. if (pointerId != this._lastPointerDownID) {
  10277. return;
  10278. }
  10279. if (this._pointerIsDown) {
  10280. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10281. }
  10282. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10283. };
  10284. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10285. this._pointerIsDown = false;
  10286. delete this._host._capturingControl[pointerId];
  10287. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10288. };
  10289. return BaseSlider;
  10290. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10291. /***/ }),
  10292. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10293. /*!*************************************************!*\
  10294. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10295. \*************************************************/
  10296. /*! exports provided: ImageBasedSlider */
  10297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10298. "use strict";
  10299. __webpack_require__.r(__webpack_exports__);
  10300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10301. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10302. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10303. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10304. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10305. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10306. /**
  10307. * Class used to create slider controls based on images
  10308. */
  10309. var ImageBasedSlider = /** @class */ (function (_super) {
  10310. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10311. /**
  10312. * Creates a new ImageBasedSlider
  10313. * @param name defines the control name
  10314. */
  10315. function ImageBasedSlider(name) {
  10316. var _this = _super.call(this, name) || this;
  10317. _this.name = name;
  10318. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10319. return _this;
  10320. }
  10321. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10322. get: function () {
  10323. return this._displayThumb && this.thumbImage != null;
  10324. },
  10325. set: function (value) {
  10326. if (this._displayThumb === value) {
  10327. return;
  10328. }
  10329. this._displayThumb = value;
  10330. this._markAsDirty();
  10331. },
  10332. enumerable: true,
  10333. configurable: true
  10334. });
  10335. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10336. /**
  10337. * Gets or sets the image used to render the background
  10338. */
  10339. get: function () {
  10340. return this._backgroundImage;
  10341. },
  10342. set: function (value) {
  10343. var _this = this;
  10344. if (this._backgroundImage === value) {
  10345. return;
  10346. }
  10347. this._backgroundImage = value;
  10348. if (value && !value.isLoaded) {
  10349. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10350. }
  10351. this._markAsDirty();
  10352. },
  10353. enumerable: true,
  10354. configurable: true
  10355. });
  10356. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10357. /**
  10358. * Gets or sets the image used to render the value bar
  10359. */
  10360. get: function () {
  10361. return this._valueBarImage;
  10362. },
  10363. set: function (value) {
  10364. var _this = this;
  10365. if (this._valueBarImage === value) {
  10366. return;
  10367. }
  10368. this._valueBarImage = value;
  10369. if (value && !value.isLoaded) {
  10370. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10371. }
  10372. this._markAsDirty();
  10373. },
  10374. enumerable: true,
  10375. configurable: true
  10376. });
  10377. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10378. /**
  10379. * Gets or sets the image used to render the thumb
  10380. */
  10381. get: function () {
  10382. return this._thumbImage;
  10383. },
  10384. set: function (value) {
  10385. var _this = this;
  10386. if (this._thumbImage === value) {
  10387. return;
  10388. }
  10389. this._thumbImage = value;
  10390. if (value && !value.isLoaded) {
  10391. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10392. }
  10393. this._markAsDirty();
  10394. },
  10395. enumerable: true,
  10396. configurable: true
  10397. });
  10398. ImageBasedSlider.prototype._getTypeName = function () {
  10399. return "ImageBasedSlider";
  10400. };
  10401. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10402. context.save();
  10403. this._applyStates(context);
  10404. this._prepareRenderingData("rectangle");
  10405. var thumbPosition = this._getThumbPosition();
  10406. var left = this._renderLeft;
  10407. var top = this._renderTop;
  10408. var width = this._renderWidth;
  10409. var height = this._renderHeight;
  10410. // Background
  10411. if (this._backgroundImage) {
  10412. this._tempMeasure.copyFromFloats(left, top, width, height);
  10413. if (this.isThumbClamped && this.displayThumb) {
  10414. if (this.isVertical) {
  10415. this._tempMeasure.height += this._effectiveThumbThickness;
  10416. }
  10417. else {
  10418. this._tempMeasure.width += this._effectiveThumbThickness;
  10419. }
  10420. }
  10421. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10422. this._backgroundImage._draw(context);
  10423. }
  10424. // Bar
  10425. if (this._valueBarImage) {
  10426. if (this.isVertical) {
  10427. if (this.isThumbClamped && this.displayThumb) {
  10428. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10429. }
  10430. else {
  10431. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10432. }
  10433. }
  10434. else {
  10435. if (this.isThumbClamped && this.displayThumb) {
  10436. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10437. }
  10438. else {
  10439. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10440. }
  10441. }
  10442. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10443. this._valueBarImage._draw(context);
  10444. }
  10445. // Thumb
  10446. if (this.displayThumb) {
  10447. if (this.isVertical) {
  10448. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10449. }
  10450. else {
  10451. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10452. }
  10453. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10454. this._thumbImage._draw(context);
  10455. }
  10456. context.restore();
  10457. };
  10458. return ImageBasedSlider;
  10459. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10460. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10461. /***/ }),
  10462. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10463. /*!***********************************************!*\
  10464. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10465. \***********************************************/
  10466. /*! exports provided: ImageScrollBar */
  10467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10468. "use strict";
  10469. __webpack_require__.r(__webpack_exports__);
  10470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10471. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10472. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10474. /**
  10475. * Class used to create slider controls
  10476. */
  10477. var ImageScrollBar = /** @class */ (function (_super) {
  10478. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  10479. /**
  10480. * Creates a new ImageScrollBar
  10481. * @param name defines the control name
  10482. */
  10483. function ImageScrollBar(name) {
  10484. var _this = _super.call(this, name) || this;
  10485. _this.name = name;
  10486. _this._thumbLength = 0.5;
  10487. _this._thumbHeight = 1;
  10488. _this._barImageHeight = 1;
  10489. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10490. return _this;
  10491. }
  10492. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  10493. /**
  10494. * Gets or sets the image used to render the background
  10495. */
  10496. get: function () {
  10497. return this._backgroundImage;
  10498. },
  10499. set: function (value) {
  10500. var _this = this;
  10501. if (this._backgroundImage === value) {
  10502. return;
  10503. }
  10504. this._backgroundImage = value;
  10505. if (value && !value.isLoaded) {
  10506. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10507. }
  10508. this._markAsDirty();
  10509. },
  10510. enumerable: true,
  10511. configurable: true
  10512. });
  10513. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  10514. /**
  10515. * Gets or sets the image used to render the thumb
  10516. */
  10517. get: function () {
  10518. return this._thumbImage;
  10519. },
  10520. set: function (value) {
  10521. var _this = this;
  10522. if (this._thumbImage === value) {
  10523. return;
  10524. }
  10525. this._thumbImage = value;
  10526. if (value && !value.isLoaded) {
  10527. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10528. }
  10529. this._markAsDirty();
  10530. },
  10531. enumerable: true,
  10532. configurable: true
  10533. });
  10534. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  10535. /**
  10536. * Gets or sets the length of the thumb
  10537. */
  10538. get: function () {
  10539. return this._thumbLength;
  10540. },
  10541. set: function (value) {
  10542. if (this._thumbLength === value) {
  10543. return;
  10544. }
  10545. this._thumbLength = value;
  10546. this._markAsDirty();
  10547. },
  10548. enumerable: true,
  10549. configurable: true
  10550. });
  10551. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  10552. /**
  10553. * Gets or sets the height of the thumb
  10554. */
  10555. get: function () {
  10556. return this._thumbHeight;
  10557. },
  10558. set: function (value) {
  10559. if (this._thumbLength === value) {
  10560. return;
  10561. }
  10562. this._thumbHeight = value;
  10563. this._markAsDirty();
  10564. },
  10565. enumerable: true,
  10566. configurable: true
  10567. });
  10568. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  10569. /**
  10570. * Gets or sets the height of the bar image
  10571. */
  10572. get: function () {
  10573. return this._barImageHeight;
  10574. },
  10575. set: function (value) {
  10576. if (this._barImageHeight === value) {
  10577. return;
  10578. }
  10579. this._barImageHeight = value;
  10580. this._markAsDirty();
  10581. },
  10582. enumerable: true,
  10583. configurable: true
  10584. });
  10585. ImageScrollBar.prototype._getTypeName = function () {
  10586. return "ImageScrollBar";
  10587. };
  10588. ImageScrollBar.prototype._getThumbThickness = function () {
  10589. var thumbThickness = 0;
  10590. if (this._thumbWidth.isPixel) {
  10591. thumbThickness = this._thumbWidth.getValue(this._host);
  10592. }
  10593. else {
  10594. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10595. }
  10596. return thumbThickness;
  10597. };
  10598. ImageScrollBar.prototype._draw = function (context) {
  10599. context.save();
  10600. this._applyStates(context);
  10601. this._prepareRenderingData("rectangle");
  10602. var thumbPosition = this._getThumbPosition();
  10603. var left = this._renderLeft;
  10604. var top = this._renderTop;
  10605. var width = this._renderWidth;
  10606. var height = this._renderHeight;
  10607. // Background
  10608. if (this._backgroundImage) {
  10609. this._tempMeasure.copyFromFloats(left, top, width, height);
  10610. if (this.isVertical) {
  10611. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  10612. this._tempMeasure.height += this._effectiveThumbThickness;
  10613. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10614. }
  10615. else {
  10616. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  10617. this._tempMeasure.width += this._effectiveThumbThickness;
  10618. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10619. }
  10620. this._backgroundImage._draw(context);
  10621. }
  10622. // Thumb
  10623. if (this.isVertical) {
  10624. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5, this._currentMeasure.top + thumbPosition, this._currentMeasure.width * this._thumbHeight, this._effectiveThumbThickness);
  10625. }
  10626. else {
  10627. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5, this._effectiveThumbThickness, this._currentMeasure.height * this._thumbHeight);
  10628. }
  10629. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10630. this._thumbImage._draw(context);
  10631. context.restore();
  10632. };
  10633. /** @hidden */
  10634. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10635. if (this.rotation != 0) {
  10636. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10637. x = this._transformedPosition.x;
  10638. y = this._transformedPosition.y;
  10639. }
  10640. if (this._first) {
  10641. this._first = false;
  10642. this._originX = x;
  10643. this._originY = y;
  10644. // Check if move is required
  10645. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10646. if (this.isVertical) {
  10647. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10648. }
  10649. else {
  10650. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10651. }
  10652. }
  10653. }
  10654. // Delta mode
  10655. var delta = 0;
  10656. if (this.isVertical) {
  10657. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10658. }
  10659. else {
  10660. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10661. }
  10662. this.value += delta * (this.maximum - this.minimum);
  10663. this._originX = x;
  10664. this._originY = y;
  10665. };
  10666. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10667. this._first = true;
  10668. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10669. };
  10670. return ImageScrollBar;
  10671. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10672. /***/ }),
  10673. /***/ "./2D/controls/sliders/scrollBar.ts":
  10674. /*!******************************************!*\
  10675. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10676. \******************************************/
  10677. /*! exports provided: ScrollBar */
  10678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10679. "use strict";
  10680. __webpack_require__.r(__webpack_exports__);
  10681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10682. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10683. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10684. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10685. /**
  10686. * Class used to create slider controls
  10687. */
  10688. var ScrollBar = /** @class */ (function (_super) {
  10689. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  10690. /**
  10691. * Creates a new Slider
  10692. * @param name defines the control name
  10693. */
  10694. function ScrollBar(name) {
  10695. var _this = _super.call(this, name) || this;
  10696. _this.name = name;
  10697. _this._background = "black";
  10698. _this._borderColor = "white";
  10699. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10700. return _this;
  10701. }
  10702. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10703. /** Gets or sets border color */
  10704. get: function () {
  10705. return this._borderColor;
  10706. },
  10707. set: function (value) {
  10708. if (this._borderColor === value) {
  10709. return;
  10710. }
  10711. this._borderColor = value;
  10712. this._markAsDirty();
  10713. },
  10714. enumerable: true,
  10715. configurable: true
  10716. });
  10717. Object.defineProperty(ScrollBar.prototype, "background", {
  10718. /** Gets or sets background color */
  10719. get: function () {
  10720. return this._background;
  10721. },
  10722. set: function (value) {
  10723. if (this._background === value) {
  10724. return;
  10725. }
  10726. this._background = value;
  10727. this._markAsDirty();
  10728. },
  10729. enumerable: true,
  10730. configurable: true
  10731. });
  10732. ScrollBar.prototype._getTypeName = function () {
  10733. return "Scrollbar";
  10734. };
  10735. ScrollBar.prototype._getThumbThickness = function () {
  10736. var thumbThickness = 0;
  10737. if (this._thumbWidth.isPixel) {
  10738. thumbThickness = this._thumbWidth.getValue(this._host);
  10739. }
  10740. else {
  10741. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10742. }
  10743. return thumbThickness;
  10744. };
  10745. ScrollBar.prototype._draw = function (context) {
  10746. context.save();
  10747. this._applyStates(context);
  10748. this._prepareRenderingData("rectangle");
  10749. var left = this._renderLeft;
  10750. var thumbPosition = this._getThumbPosition();
  10751. context.fillStyle = this._background;
  10752. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10753. // Value bar
  10754. context.fillStyle = this.color;
  10755. // Thumb
  10756. if (this.isVertical) {
  10757. this._tempMeasure.left = left - this._effectiveBarOffset;
  10758. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  10759. this._tempMeasure.width = this._currentMeasure.width;
  10760. this._tempMeasure.height = this._effectiveThumbThickness;
  10761. }
  10762. else {
  10763. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  10764. this._tempMeasure.top = this._currentMeasure.top;
  10765. this._tempMeasure.width = this._effectiveThumbThickness;
  10766. this._tempMeasure.height = this._currentMeasure.height;
  10767. }
  10768. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  10769. context.restore();
  10770. };
  10771. /** @hidden */
  10772. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10773. if (this.rotation != 0) {
  10774. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10775. x = this._transformedPosition.x;
  10776. y = this._transformedPosition.y;
  10777. }
  10778. if (this._first) {
  10779. this._first = false;
  10780. this._originX = x;
  10781. this._originY = y;
  10782. // Check if move is required
  10783. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10784. if (this.isVertical) {
  10785. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10786. }
  10787. else {
  10788. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10789. }
  10790. }
  10791. }
  10792. // Delta mode
  10793. var delta = 0;
  10794. if (this.isVertical) {
  10795. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10796. }
  10797. else {
  10798. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10799. }
  10800. this.value += delta * (this.maximum - this.minimum);
  10801. this._originX = x;
  10802. this._originY = y;
  10803. };
  10804. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10805. this._first = true;
  10806. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10807. };
  10808. return ScrollBar;
  10809. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10810. /***/ }),
  10811. /***/ "./2D/controls/sliders/slider.ts":
  10812. /*!***************************************!*\
  10813. !*** ./2D/controls/sliders/slider.ts ***!
  10814. \***************************************/
  10815. /*! exports provided: Slider */
  10816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10817. "use strict";
  10818. __webpack_require__.r(__webpack_exports__);
  10819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10821. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10822. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10823. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  10824. /**
  10825. * Class used to create slider controls
  10826. */
  10827. var Slider = /** @class */ (function (_super) {
  10828. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  10829. /**
  10830. * Creates a new Slider
  10831. * @param name defines the control name
  10832. */
  10833. function Slider(name) {
  10834. var _this = _super.call(this, name) || this;
  10835. _this.name = name;
  10836. _this._background = "black";
  10837. _this._borderColor = "white";
  10838. _this._isThumbCircle = false;
  10839. _this._displayValueBar = true;
  10840. return _this;
  10841. }
  10842. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10843. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10844. get: function () {
  10845. return this._displayValueBar;
  10846. },
  10847. set: function (value) {
  10848. if (this._displayValueBar === value) {
  10849. return;
  10850. }
  10851. this._displayValueBar = value;
  10852. this._markAsDirty();
  10853. },
  10854. enumerable: true,
  10855. configurable: true
  10856. });
  10857. Object.defineProperty(Slider.prototype, "borderColor", {
  10858. /** Gets or sets border color */
  10859. get: function () {
  10860. return this._borderColor;
  10861. },
  10862. set: function (value) {
  10863. if (this._borderColor === value) {
  10864. return;
  10865. }
  10866. this._borderColor = value;
  10867. this._markAsDirty();
  10868. },
  10869. enumerable: true,
  10870. configurable: true
  10871. });
  10872. Object.defineProperty(Slider.prototype, "background", {
  10873. /** Gets or sets background color */
  10874. get: function () {
  10875. return this._background;
  10876. },
  10877. set: function (value) {
  10878. if (this._background === value) {
  10879. return;
  10880. }
  10881. this._background = value;
  10882. this._markAsDirty();
  10883. },
  10884. enumerable: true,
  10885. configurable: true
  10886. });
  10887. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10888. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10889. get: function () {
  10890. return this._isThumbCircle;
  10891. },
  10892. set: function (value) {
  10893. if (this._isThumbCircle === value) {
  10894. return;
  10895. }
  10896. this._isThumbCircle = value;
  10897. this._markAsDirty();
  10898. },
  10899. enumerable: true,
  10900. configurable: true
  10901. });
  10902. Slider.prototype._getTypeName = function () {
  10903. return "Slider";
  10904. };
  10905. Slider.prototype._draw = function (context, invalidatedRectangle) {
  10906. context.save();
  10907. this._applyStates(context);
  10908. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10909. var left = this._renderLeft;
  10910. var top = this._renderTop;
  10911. var width = this._renderWidth;
  10912. var height = this._renderHeight;
  10913. var radius = 0;
  10914. if (this.isThumbClamped && this.isThumbCircle) {
  10915. if (this.isVertical) {
  10916. top += (this._effectiveThumbThickness / 2);
  10917. }
  10918. else {
  10919. left += (this._effectiveThumbThickness / 2);
  10920. }
  10921. radius = this._backgroundBoxThickness / 2;
  10922. }
  10923. else {
  10924. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10925. }
  10926. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10927. context.shadowColor = this.shadowColor;
  10928. context.shadowBlur = this.shadowBlur;
  10929. context.shadowOffsetX = this.shadowOffsetX;
  10930. context.shadowOffsetY = this.shadowOffsetY;
  10931. }
  10932. var thumbPosition = this._getThumbPosition();
  10933. context.fillStyle = this._background;
  10934. if (this.isVertical) {
  10935. if (this.isThumbClamped) {
  10936. if (this.isThumbCircle) {
  10937. context.beginPath();
  10938. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10939. context.fill();
  10940. context.fillRect(left, top, width, height);
  10941. }
  10942. else {
  10943. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10944. }
  10945. }
  10946. else {
  10947. context.fillRect(left, top, width, height);
  10948. }
  10949. }
  10950. else {
  10951. if (this.isThumbClamped) {
  10952. if (this.isThumbCircle) {
  10953. context.beginPath();
  10954. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10955. context.fill();
  10956. context.fillRect(left, top, width, height);
  10957. }
  10958. else {
  10959. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10960. }
  10961. }
  10962. else {
  10963. context.fillRect(left, top, width, height);
  10964. }
  10965. }
  10966. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10967. context.shadowBlur = 0;
  10968. context.shadowOffsetX = 0;
  10969. context.shadowOffsetY = 0;
  10970. }
  10971. // Value bar
  10972. context.fillStyle = this.color;
  10973. if (this._displayValueBar) {
  10974. if (this.isVertical) {
  10975. if (this.isThumbClamped) {
  10976. if (this.isThumbCircle) {
  10977. context.beginPath();
  10978. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10979. context.fill();
  10980. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10981. }
  10982. else {
  10983. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10984. }
  10985. }
  10986. else {
  10987. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10988. }
  10989. }
  10990. else {
  10991. if (this.isThumbClamped) {
  10992. if (this.isThumbCircle) {
  10993. context.beginPath();
  10994. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10995. context.fill();
  10996. context.fillRect(left, top, thumbPosition, height);
  10997. }
  10998. else {
  10999. context.fillRect(left, top, thumbPosition, height);
  11000. }
  11001. }
  11002. else {
  11003. context.fillRect(left, top, thumbPosition, height);
  11004. }
  11005. }
  11006. }
  11007. // Thumb
  11008. if (this.displayThumb) {
  11009. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11010. context.shadowColor = this.shadowColor;
  11011. context.shadowBlur = this.shadowBlur;
  11012. context.shadowOffsetX = this.shadowOffsetX;
  11013. context.shadowOffsetY = this.shadowOffsetY;
  11014. }
  11015. if (this._isThumbCircle) {
  11016. context.beginPath();
  11017. if (this.isVertical) {
  11018. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11019. }
  11020. else {
  11021. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11022. }
  11023. context.fill();
  11024. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11025. context.shadowBlur = 0;
  11026. context.shadowOffsetX = 0;
  11027. context.shadowOffsetY = 0;
  11028. }
  11029. context.strokeStyle = this._borderColor;
  11030. context.stroke();
  11031. }
  11032. else {
  11033. if (this.isVertical) {
  11034. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11035. }
  11036. else {
  11037. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11038. }
  11039. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11040. context.shadowBlur = 0;
  11041. context.shadowOffsetX = 0;
  11042. context.shadowOffsetY = 0;
  11043. }
  11044. context.strokeStyle = this._borderColor;
  11045. if (this.isVertical) {
  11046. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11047. }
  11048. else {
  11049. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11050. }
  11051. }
  11052. }
  11053. context.restore();
  11054. };
  11055. return Slider;
  11056. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11057. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11058. /***/ }),
  11059. /***/ "./2D/controls/stackPanel.ts":
  11060. /*!***********************************!*\
  11061. !*** ./2D/controls/stackPanel.ts ***!
  11062. \***********************************/
  11063. /*! exports provided: StackPanel */
  11064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11065. "use strict";
  11066. __webpack_require__.r(__webpack_exports__);
  11067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11068. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11069. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  11070. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11071. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11072. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11073. /**
  11074. * Class used to create a 2D stack panel container
  11075. */
  11076. var StackPanel = /** @class */ (function (_super) {
  11077. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11078. /**
  11079. * Creates a new StackPanel
  11080. * @param name defines control name
  11081. */
  11082. function StackPanel(name) {
  11083. var _this = _super.call(this, name) || this;
  11084. _this.name = name;
  11085. _this._isVertical = true;
  11086. _this._manualWidth = false;
  11087. _this._manualHeight = false;
  11088. _this._doNotTrackManualChanges = false;
  11089. /**
  11090. * Gets or sets a boolean indicating that layou warnings should be ignored
  11091. */
  11092. _this.ignoreLayoutWarnings = false;
  11093. return _this;
  11094. }
  11095. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11096. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11097. get: function () {
  11098. return this._isVertical;
  11099. },
  11100. set: function (value) {
  11101. if (this._isVertical === value) {
  11102. return;
  11103. }
  11104. this._isVertical = value;
  11105. this._markAsDirty();
  11106. },
  11107. enumerable: true,
  11108. configurable: true
  11109. });
  11110. Object.defineProperty(StackPanel.prototype, "width", {
  11111. get: function () {
  11112. return this._width.toString(this._host);
  11113. },
  11114. /**
  11115. * Gets or sets panel width.
  11116. * This value should not be set when in horizontal mode as it will be computed automatically
  11117. */
  11118. set: function (value) {
  11119. if (!this._doNotTrackManualChanges) {
  11120. this._manualWidth = true;
  11121. }
  11122. if (this._width.toString(this._host) === value) {
  11123. return;
  11124. }
  11125. if (this._width.fromString(value)) {
  11126. this._markAsDirty();
  11127. }
  11128. },
  11129. enumerable: true,
  11130. configurable: true
  11131. });
  11132. Object.defineProperty(StackPanel.prototype, "height", {
  11133. get: function () {
  11134. return this._height.toString(this._host);
  11135. },
  11136. /**
  11137. * Gets or sets panel height.
  11138. * This value should not be set when in vertical mode as it will be computed automatically
  11139. */
  11140. set: function (value) {
  11141. if (!this._doNotTrackManualChanges) {
  11142. this._manualHeight = true;
  11143. }
  11144. if (this._height.toString(this._host) === value) {
  11145. return;
  11146. }
  11147. if (this._height.fromString(value)) {
  11148. this._markAsDirty();
  11149. }
  11150. },
  11151. enumerable: true,
  11152. configurable: true
  11153. });
  11154. StackPanel.prototype._getTypeName = function () {
  11155. return "StackPanel";
  11156. };
  11157. /** @hidden */
  11158. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11159. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11160. var child = _a[_i];
  11161. if (this._isVertical) {
  11162. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11163. }
  11164. else {
  11165. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11166. }
  11167. }
  11168. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11169. };
  11170. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11171. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11172. this._measureForChildren.copyFrom(parentMeasure);
  11173. this._measureForChildren.left = this._currentMeasure.left;
  11174. this._measureForChildren.top = this._currentMeasure.top;
  11175. if (!this.isVertical || this._manualWidth) {
  11176. this._measureForChildren.width = this._currentMeasure.width;
  11177. }
  11178. if (this.isVertical || this._manualHeight) {
  11179. this._measureForChildren.height = this._currentMeasure.height;
  11180. }
  11181. };
  11182. StackPanel.prototype._postMeasure = function () {
  11183. var stackWidth = 0;
  11184. var stackHeight = 0;
  11185. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11186. var child = _a[_i];
  11187. if (!child.isVisible || child.notRenderable) {
  11188. continue;
  11189. }
  11190. if (this._isVertical) {
  11191. if (child.top !== stackHeight + "px") {
  11192. child.top = stackHeight + "px";
  11193. this._rebuildLayout = true;
  11194. child._top.ignoreAdaptiveScaling = true;
  11195. }
  11196. if (child._height.isPercentage && !child._automaticSize) {
  11197. if (!this.ignoreLayoutWarnings) {
  11198. 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");
  11199. }
  11200. }
  11201. else {
  11202. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11203. }
  11204. }
  11205. else {
  11206. if (child.left !== stackWidth + "px") {
  11207. child.left = stackWidth + "px";
  11208. this._rebuildLayout = true;
  11209. child._left.ignoreAdaptiveScaling = true;
  11210. }
  11211. if (child._width.isPercentage && !child._automaticSize) {
  11212. if (!this.ignoreLayoutWarnings) {
  11213. 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");
  11214. }
  11215. }
  11216. else {
  11217. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11218. }
  11219. }
  11220. }
  11221. this._doNotTrackManualChanges = true;
  11222. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11223. // User can now define their own height and width for stack panel.
  11224. var panelWidthChanged = false;
  11225. var panelHeightChanged = false;
  11226. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11227. var previousHeight = this.height;
  11228. this.height = stackHeight + "px";
  11229. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11230. }
  11231. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11232. var previousWidth = this.width;
  11233. this.width = stackWidth + "px";
  11234. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11235. }
  11236. if (panelHeightChanged) {
  11237. this._height.ignoreAdaptiveScaling = true;
  11238. }
  11239. if (panelWidthChanged) {
  11240. this._width.ignoreAdaptiveScaling = true;
  11241. }
  11242. this._doNotTrackManualChanges = false;
  11243. if (panelWidthChanged || panelHeightChanged) {
  11244. this._rebuildLayout = true;
  11245. }
  11246. _super.prototype._postMeasure.call(this);
  11247. };
  11248. return StackPanel;
  11249. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11250. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11251. /***/ }),
  11252. /***/ "./2D/controls/statics.ts":
  11253. /*!********************************!*\
  11254. !*** ./2D/controls/statics.ts ***!
  11255. \********************************/
  11256. /*! exports provided: name */
  11257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11258. "use strict";
  11259. __webpack_require__.r(__webpack_exports__);
  11260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11261. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11262. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11263. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11264. /**
  11265. * Forcing an export so that this code will execute
  11266. * @hidden
  11267. */
  11268. var name = "Statics";
  11269. /**
  11270. * Creates a stack panel that can be used to render headers
  11271. * @param control defines the control to associate with the header
  11272. * @param text defines the text of the header
  11273. * @param size defines the size of the header
  11274. * @param options defines options used to configure the header
  11275. * @returns a new StackPanel
  11276. */
  11277. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11278. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11279. var isHorizontal = options ? options.isHorizontal : true;
  11280. var controlFirst = options ? options.controlFirst : true;
  11281. panel.isVertical = !isHorizontal;
  11282. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11283. header.text = text;
  11284. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11285. if (isHorizontal) {
  11286. header.width = size;
  11287. }
  11288. else {
  11289. header.height = size;
  11290. }
  11291. if (controlFirst) {
  11292. panel.addControl(control);
  11293. panel.addControl(header);
  11294. header.paddingLeft = "5px";
  11295. }
  11296. else {
  11297. panel.addControl(header);
  11298. panel.addControl(control);
  11299. header.paddingRight = "5px";
  11300. }
  11301. header.shadowBlur = control.shadowBlur;
  11302. header.shadowColor = control.shadowColor;
  11303. header.shadowOffsetX = control.shadowOffsetX;
  11304. header.shadowOffsetY = control.shadowOffsetY;
  11305. return panel;
  11306. };
  11307. /***/ }),
  11308. /***/ "./2D/controls/textBlock.ts":
  11309. /*!**********************************!*\
  11310. !*** ./2D/controls/textBlock.ts ***!
  11311. \**********************************/
  11312. /*! exports provided: TextWrapping, TextBlock */
  11313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11314. "use strict";
  11315. __webpack_require__.r(__webpack_exports__);
  11316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11318. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11319. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11320. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11321. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11322. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11323. /**
  11324. * Enum that determines the text-wrapping mode to use.
  11325. */
  11326. var TextWrapping;
  11327. (function (TextWrapping) {
  11328. /**
  11329. * Clip the text when it's larger than Control.width; this is the default mode.
  11330. */
  11331. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11332. /**
  11333. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11334. */
  11335. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11336. /**
  11337. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11338. */
  11339. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11340. })(TextWrapping || (TextWrapping = {}));
  11341. /**
  11342. * Class used to create text block control
  11343. */
  11344. var TextBlock = /** @class */ (function (_super) {
  11345. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11346. /**
  11347. * Creates a new TextBlock object
  11348. * @param name defines the name of the control
  11349. * @param text defines the text to display (emptry string by default)
  11350. */
  11351. function TextBlock(
  11352. /**
  11353. * Defines the name of the control
  11354. */
  11355. name, text) {
  11356. if (text === void 0) { text = ""; }
  11357. var _this = _super.call(this, name) || this;
  11358. _this.name = name;
  11359. _this._text = "";
  11360. _this._textWrapping = TextWrapping.Clip;
  11361. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11362. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11363. _this._resizeToFit = false;
  11364. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11365. _this._outlineWidth = 0;
  11366. _this._outlineColor = "white";
  11367. /**
  11368. * An event triggered after the text is changed
  11369. */
  11370. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11371. /**
  11372. * An event triggered after the text was broken up into lines
  11373. */
  11374. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11375. _this.text = text;
  11376. return _this;
  11377. }
  11378. Object.defineProperty(TextBlock.prototype, "lines", {
  11379. /**
  11380. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11381. */
  11382. get: function () {
  11383. return this._lines;
  11384. },
  11385. enumerable: true,
  11386. configurable: true
  11387. });
  11388. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11389. /**
  11390. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11391. */
  11392. get: function () {
  11393. return this._resizeToFit;
  11394. },
  11395. /**
  11396. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11397. */
  11398. set: function (value) {
  11399. if (this._resizeToFit === value) {
  11400. return;
  11401. }
  11402. this._resizeToFit = value;
  11403. if (this._resizeToFit) {
  11404. this._width.ignoreAdaptiveScaling = true;
  11405. this._height.ignoreAdaptiveScaling = true;
  11406. }
  11407. this._markAsDirty();
  11408. },
  11409. enumerable: true,
  11410. configurable: true
  11411. });
  11412. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11413. /**
  11414. * Gets or sets a boolean indicating if text must be wrapped
  11415. */
  11416. get: function () {
  11417. return this._textWrapping;
  11418. },
  11419. /**
  11420. * Gets or sets a boolean indicating if text must be wrapped
  11421. */
  11422. set: function (value) {
  11423. if (this._textWrapping === value) {
  11424. return;
  11425. }
  11426. this._textWrapping = +value;
  11427. this._markAsDirty();
  11428. },
  11429. enumerable: true,
  11430. configurable: true
  11431. });
  11432. Object.defineProperty(TextBlock.prototype, "text", {
  11433. /**
  11434. * Gets or sets text to display
  11435. */
  11436. get: function () {
  11437. return this._text;
  11438. },
  11439. /**
  11440. * Gets or sets text to display
  11441. */
  11442. set: function (value) {
  11443. if (this._text === value) {
  11444. return;
  11445. }
  11446. this._text = value;
  11447. this._markAsDirty();
  11448. this.onTextChangedObservable.notifyObservers(this);
  11449. },
  11450. enumerable: true,
  11451. configurable: true
  11452. });
  11453. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11454. /**
  11455. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11456. */
  11457. get: function () {
  11458. return this._textHorizontalAlignment;
  11459. },
  11460. /**
  11461. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11462. */
  11463. set: function (value) {
  11464. if (this._textHorizontalAlignment === value) {
  11465. return;
  11466. }
  11467. this._textHorizontalAlignment = value;
  11468. this._markAsDirty();
  11469. },
  11470. enumerable: true,
  11471. configurable: true
  11472. });
  11473. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11474. /**
  11475. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11476. */
  11477. get: function () {
  11478. return this._textVerticalAlignment;
  11479. },
  11480. /**
  11481. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11482. */
  11483. set: function (value) {
  11484. if (this._textVerticalAlignment === value) {
  11485. return;
  11486. }
  11487. this._textVerticalAlignment = value;
  11488. this._markAsDirty();
  11489. },
  11490. enumerable: true,
  11491. configurable: true
  11492. });
  11493. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11494. /**
  11495. * Gets or sets line spacing value
  11496. */
  11497. get: function () {
  11498. return this._lineSpacing.toString(this._host);
  11499. },
  11500. /**
  11501. * Gets or sets line spacing value
  11502. */
  11503. set: function (value) {
  11504. if (this._lineSpacing.fromString(value)) {
  11505. this._markAsDirty();
  11506. }
  11507. },
  11508. enumerable: true,
  11509. configurable: true
  11510. });
  11511. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11512. /**
  11513. * Gets or sets outlineWidth of the text to display
  11514. */
  11515. get: function () {
  11516. return this._outlineWidth;
  11517. },
  11518. /**
  11519. * Gets or sets outlineWidth of the text to display
  11520. */
  11521. set: function (value) {
  11522. if (this._outlineWidth === value) {
  11523. return;
  11524. }
  11525. this._outlineWidth = value;
  11526. this._markAsDirty();
  11527. },
  11528. enumerable: true,
  11529. configurable: true
  11530. });
  11531. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11532. /**
  11533. * Gets or sets outlineColor of the text to display
  11534. */
  11535. get: function () {
  11536. return this._outlineColor;
  11537. },
  11538. /**
  11539. * Gets or sets outlineColor of the text to display
  11540. */
  11541. set: function (value) {
  11542. if (this._outlineColor === value) {
  11543. return;
  11544. }
  11545. this._outlineColor = value;
  11546. this._markAsDirty();
  11547. },
  11548. enumerable: true,
  11549. configurable: true
  11550. });
  11551. TextBlock.prototype._getTypeName = function () {
  11552. return "TextBlock";
  11553. };
  11554. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11555. if (!this._fontOffset) {
  11556. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11557. }
  11558. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11559. // Prepare lines
  11560. this._lines = this._breakLines(this._currentMeasure.width, context);
  11561. this.onLinesReadyObservable.notifyObservers(this);
  11562. var maxLineWidth = 0;
  11563. for (var i = 0; i < this._lines.length; i++) {
  11564. var line = this._lines[i];
  11565. if (line.width > maxLineWidth) {
  11566. maxLineWidth = line.width;
  11567. }
  11568. }
  11569. if (this._resizeToFit) {
  11570. if (this._textWrapping === TextWrapping.Clip) {
  11571. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11572. if (newWidth !== this._width.internalValue) {
  11573. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11574. this._rebuildLayout = true;
  11575. }
  11576. }
  11577. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11578. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11579. var lineSpacing = 0;
  11580. if (this._lineSpacing.isPixel) {
  11581. lineSpacing = this._lineSpacing.getValue(this._host);
  11582. }
  11583. else {
  11584. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11585. }
  11586. newHeight += (this._lines.length - 1) * lineSpacing;
  11587. }
  11588. if (newHeight !== this._height.internalValue) {
  11589. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11590. this._rebuildLayout = true;
  11591. }
  11592. }
  11593. };
  11594. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11595. var width = this._currentMeasure.width;
  11596. var x = 0;
  11597. switch (this._textHorizontalAlignment) {
  11598. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11599. x = 0;
  11600. break;
  11601. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11602. x = width - textWidth;
  11603. break;
  11604. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11605. x = (width - textWidth) / 2;
  11606. break;
  11607. }
  11608. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11609. context.shadowColor = this.shadowColor;
  11610. context.shadowBlur = this.shadowBlur;
  11611. context.shadowOffsetX = this.shadowOffsetX;
  11612. context.shadowOffsetY = this.shadowOffsetY;
  11613. }
  11614. if (this.outlineWidth) {
  11615. context.strokeText(text, this._currentMeasure.left + x, y);
  11616. }
  11617. context.fillText(text, this._currentMeasure.left + x, y);
  11618. };
  11619. /** @hidden */
  11620. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  11621. context.save();
  11622. this._applyStates(context);
  11623. // Render lines
  11624. this._renderLines(context);
  11625. context.restore();
  11626. };
  11627. TextBlock.prototype._applyStates = function (context) {
  11628. _super.prototype._applyStates.call(this, context);
  11629. if (this.outlineWidth) {
  11630. context.lineWidth = this.outlineWidth;
  11631. context.strokeStyle = this.outlineColor;
  11632. }
  11633. };
  11634. TextBlock.prototype._breakLines = function (refWidth, context) {
  11635. var lines = [];
  11636. var _lines = this.text.split("\n");
  11637. if (this._textWrapping === TextWrapping.Ellipsis) {
  11638. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11639. var _line = _lines_1[_i];
  11640. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11641. }
  11642. }
  11643. else if (this._textWrapping === TextWrapping.WordWrap) {
  11644. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11645. var _line = _lines_2[_a];
  11646. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11647. }
  11648. }
  11649. else {
  11650. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11651. var _line = _lines_3[_b];
  11652. lines.push(this._parseLine(_line, context));
  11653. }
  11654. }
  11655. return lines;
  11656. };
  11657. TextBlock.prototype._parseLine = function (line, context) {
  11658. if (line === void 0) { line = ''; }
  11659. return { text: line, width: context.measureText(line).width };
  11660. };
  11661. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11662. if (line === void 0) { line = ''; }
  11663. var lineWidth = context.measureText(line).width;
  11664. if (lineWidth > width) {
  11665. line += '…';
  11666. }
  11667. while (line.length > 2 && lineWidth > width) {
  11668. line = line.slice(0, -2) + '…';
  11669. lineWidth = context.measureText(line).width;
  11670. }
  11671. return { text: line, width: lineWidth };
  11672. };
  11673. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11674. if (line === void 0) { line = ''; }
  11675. var lines = [];
  11676. var words = line.split(' ');
  11677. var lineWidth = 0;
  11678. for (var n = 0; n < words.length; n++) {
  11679. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11680. var metrics = context.measureText(testLine);
  11681. var testWidth = metrics.width;
  11682. if (testWidth > width && n > 0) {
  11683. lines.push({ text: line, width: lineWidth });
  11684. line = words[n];
  11685. lineWidth = context.measureText(line).width;
  11686. }
  11687. else {
  11688. lineWidth = testWidth;
  11689. line = testLine;
  11690. }
  11691. }
  11692. lines.push({ text: line, width: lineWidth });
  11693. return lines;
  11694. };
  11695. TextBlock.prototype._renderLines = function (context) {
  11696. var height = this._currentMeasure.height;
  11697. var rootY = 0;
  11698. switch (this._textVerticalAlignment) {
  11699. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11700. rootY = this._fontOffset.ascent;
  11701. break;
  11702. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11703. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11704. break;
  11705. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11706. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11707. break;
  11708. }
  11709. rootY += this._currentMeasure.top;
  11710. for (var i = 0; i < this._lines.length; i++) {
  11711. var line = this._lines[i];
  11712. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11713. if (this._lineSpacing.isPixel) {
  11714. rootY += this._lineSpacing.getValue(this._host);
  11715. }
  11716. else {
  11717. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11718. }
  11719. }
  11720. this._drawText(line.text, line.width, rootY, context);
  11721. rootY += this._fontOffset.height;
  11722. }
  11723. };
  11724. /**
  11725. * Given a width constraint applied on the text block, find the expected height
  11726. * @returns expected height
  11727. */
  11728. TextBlock.prototype.computeExpectedHeight = function () {
  11729. if (this.text && this.widthInPixels) {
  11730. var context_1 = document.createElement('canvas').getContext('2d');
  11731. if (context_1) {
  11732. this._applyStates(context_1);
  11733. if (!this._fontOffset) {
  11734. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11735. }
  11736. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11737. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11738. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11739. var lineSpacing = 0;
  11740. if (this._lineSpacing.isPixel) {
  11741. lineSpacing = this._lineSpacing.getValue(this._host);
  11742. }
  11743. else {
  11744. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11745. }
  11746. newHeight += (lines.length - 1) * lineSpacing;
  11747. }
  11748. return newHeight;
  11749. }
  11750. }
  11751. return 0;
  11752. };
  11753. TextBlock.prototype.dispose = function () {
  11754. _super.prototype.dispose.call(this);
  11755. this.onTextChangedObservable.clear();
  11756. };
  11757. return TextBlock;
  11758. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11759. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  11760. /***/ }),
  11761. /***/ "./2D/controls/virtualKeyboard.ts":
  11762. /*!****************************************!*\
  11763. !*** ./2D/controls/virtualKeyboard.ts ***!
  11764. \****************************************/
  11765. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11767. "use strict";
  11768. __webpack_require__.r(__webpack_exports__);
  11769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11772. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11773. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11774. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11775. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11776. /**
  11777. * Class used to store key control properties
  11778. */
  11779. var KeyPropertySet = /** @class */ (function () {
  11780. function KeyPropertySet() {
  11781. }
  11782. return KeyPropertySet;
  11783. }());
  11784. /**
  11785. * Class used to create virtual keyboard
  11786. */
  11787. var VirtualKeyboard = /** @class */ (function (_super) {
  11788. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  11789. function VirtualKeyboard() {
  11790. var _this = _super !== null && _super.apply(this, arguments) || this;
  11791. /** Observable raised when a key is pressed */
  11792. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11793. /** Gets or sets default key button width */
  11794. _this.defaultButtonWidth = "40px";
  11795. /** Gets or sets default key button height */
  11796. _this.defaultButtonHeight = "40px";
  11797. /** Gets or sets default key button left padding */
  11798. _this.defaultButtonPaddingLeft = "2px";
  11799. /** Gets or sets default key button right padding */
  11800. _this.defaultButtonPaddingRight = "2px";
  11801. /** Gets or sets default key button top padding */
  11802. _this.defaultButtonPaddingTop = "2px";
  11803. /** Gets or sets default key button bottom padding */
  11804. _this.defaultButtonPaddingBottom = "2px";
  11805. /** Gets or sets default key button foreground color */
  11806. _this.defaultButtonColor = "#DDD";
  11807. /** Gets or sets default key button background color */
  11808. _this.defaultButtonBackground = "#070707";
  11809. /** Gets or sets shift button foreground color */
  11810. _this.shiftButtonColor = "#7799FF";
  11811. /** Gets or sets shift button thickness*/
  11812. _this.selectedShiftThickness = 1;
  11813. /** Gets shift key state */
  11814. _this.shiftState = 0;
  11815. _this._currentlyConnectedInputText = null;
  11816. _this._connectedInputTexts = [];
  11817. _this._onKeyPressObserver = null;
  11818. return _this;
  11819. }
  11820. VirtualKeyboard.prototype._getTypeName = function () {
  11821. return "VirtualKeyboard";
  11822. };
  11823. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11824. var _this = this;
  11825. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11826. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11827. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11828. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11829. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11830. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11831. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11832. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11833. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11834. button.thickness = 0;
  11835. button.isFocusInvisible = true;
  11836. button.shadowColor = this.shadowColor;
  11837. button.shadowBlur = this.shadowBlur;
  11838. button.shadowOffsetX = this.shadowOffsetX;
  11839. button.shadowOffsetY = this.shadowOffsetY;
  11840. button.onPointerUpObservable.add(function () {
  11841. _this.onKeyPressObservable.notifyObservers(key);
  11842. });
  11843. return button;
  11844. };
  11845. /**
  11846. * Adds a new row of keys
  11847. * @param keys defines the list of keys to add
  11848. * @param propertySets defines the associated property sets
  11849. */
  11850. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11851. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11852. panel.isVertical = false;
  11853. panel.isFocusInvisible = true;
  11854. var maxKey = null;
  11855. for (var i = 0; i < keys.length; i++) {
  11856. var properties = null;
  11857. if (propertySets && propertySets.length === keys.length) {
  11858. properties = propertySets[i];
  11859. }
  11860. var key = this._createKey(keys[i], properties);
  11861. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11862. maxKey = key;
  11863. }
  11864. panel.addControl(key);
  11865. }
  11866. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11867. this.addControl(panel);
  11868. };
  11869. /**
  11870. * Set the shift key to a specific state
  11871. * @param shiftState defines the new shift state
  11872. */
  11873. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11874. if (!this.children) {
  11875. return;
  11876. }
  11877. for (var i = 0; i < this.children.length; i++) {
  11878. var row = this.children[i];
  11879. if (!row || !row.children) {
  11880. continue;
  11881. }
  11882. var rowContainer = row;
  11883. for (var j = 0; j < rowContainer.children.length; j++) {
  11884. var button = rowContainer.children[j];
  11885. if (!button || !button.children[0]) {
  11886. continue;
  11887. }
  11888. var button_tblock = button.children[0];
  11889. if (button_tblock.text === "\u21E7") {
  11890. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11891. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11892. }
  11893. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11894. }
  11895. }
  11896. };
  11897. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11898. /** Gets the input text control currently attached to the keyboard */
  11899. get: function () {
  11900. return this._currentlyConnectedInputText;
  11901. },
  11902. enumerable: true,
  11903. configurable: true
  11904. });
  11905. /**
  11906. * Connects the keyboard with an input text control
  11907. *
  11908. * @param input defines the target control
  11909. */
  11910. VirtualKeyboard.prototype.connect = function (input) {
  11911. var _this = this;
  11912. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11913. if (inputTextAlreadyConnected) {
  11914. return;
  11915. }
  11916. if (this._onKeyPressObserver === null) {
  11917. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11918. if (!_this._currentlyConnectedInputText) {
  11919. return;
  11920. }
  11921. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11922. switch (key) {
  11923. case "\u21E7":
  11924. _this.shiftState++;
  11925. if (_this.shiftState > 2) {
  11926. _this.shiftState = 0;
  11927. }
  11928. _this.applyShiftState(_this.shiftState);
  11929. return;
  11930. case "\u2190":
  11931. _this._currentlyConnectedInputText.processKey(8);
  11932. return;
  11933. case "\u21B5":
  11934. _this._currentlyConnectedInputText.processKey(13);
  11935. return;
  11936. }
  11937. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11938. if (_this.shiftState === 1) {
  11939. _this.shiftState = 0;
  11940. _this.applyShiftState(_this.shiftState);
  11941. }
  11942. });
  11943. }
  11944. this.isVisible = false;
  11945. this._currentlyConnectedInputText = input;
  11946. input._connectedVirtualKeyboard = this;
  11947. // Events hooking
  11948. var onFocusObserver = input.onFocusObservable.add(function () {
  11949. _this._currentlyConnectedInputText = input;
  11950. input._connectedVirtualKeyboard = _this;
  11951. _this.isVisible = true;
  11952. });
  11953. var onBlurObserver = input.onBlurObservable.add(function () {
  11954. input._connectedVirtualKeyboard = null;
  11955. _this._currentlyConnectedInputText = null;
  11956. _this.isVisible = false;
  11957. });
  11958. this._connectedInputTexts.push({
  11959. input: input,
  11960. onBlurObserver: onBlurObserver,
  11961. onFocusObserver: onFocusObserver
  11962. });
  11963. };
  11964. /**
  11965. * Disconnects the keyboard from connected InputText controls
  11966. *
  11967. * @param input optionally defines a target control, otherwise all are disconnected
  11968. */
  11969. VirtualKeyboard.prototype.disconnect = function (input) {
  11970. var _this = this;
  11971. if (input) {
  11972. // .find not available on IE
  11973. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11974. if (filtered.length === 1) {
  11975. this._removeConnectedInputObservables(filtered[0]);
  11976. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11977. if (this._currentlyConnectedInputText === input) {
  11978. this._currentlyConnectedInputText = null;
  11979. }
  11980. }
  11981. }
  11982. else {
  11983. this._connectedInputTexts.forEach(function (connectedInputText) {
  11984. _this._removeConnectedInputObservables(connectedInputText);
  11985. });
  11986. this._connectedInputTexts = [];
  11987. }
  11988. if (this._connectedInputTexts.length === 0) {
  11989. this._currentlyConnectedInputText = null;
  11990. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11991. this._onKeyPressObserver = null;
  11992. }
  11993. };
  11994. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11995. connectedInputText.input._connectedVirtualKeyboard = null;
  11996. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11997. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11998. };
  11999. /**
  12000. * Release all resources
  12001. */
  12002. VirtualKeyboard.prototype.dispose = function () {
  12003. _super.prototype.dispose.call(this);
  12004. this.disconnect();
  12005. };
  12006. // Statics
  12007. /**
  12008. * Creates a new keyboard using a default layout
  12009. *
  12010. * @param name defines control name
  12011. * @returns a new VirtualKeyboard
  12012. */
  12013. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12014. var returnValue = new VirtualKeyboard(name);
  12015. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12016. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12017. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12018. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12019. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12020. return returnValue;
  12021. };
  12022. return VirtualKeyboard;
  12023. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12024. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12025. /***/ }),
  12026. /***/ "./2D/index.ts":
  12027. /*!*********************!*\
  12028. !*** ./2D/index.ts ***!
  12029. \*********************/
  12030. /*! 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, ImageScrollBar, name */
  12031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12032. "use strict";
  12033. __webpack_require__.r(__webpack_exports__);
  12034. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12067. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12069. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12071. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12074. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12076. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12078. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12080. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12082. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12084. /***/ }),
  12085. /***/ "./2D/math2D.ts":
  12086. /*!**********************!*\
  12087. !*** ./2D/math2D.ts ***!
  12088. \**********************/
  12089. /*! exports provided: Vector2WithInfo, Matrix2D */
  12090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12091. "use strict";
  12092. __webpack_require__.r(__webpack_exports__);
  12093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12095. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12096. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12097. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12098. /**
  12099. * Class used to transport Vector2 information for pointer events
  12100. */
  12101. var Vector2WithInfo = /** @class */ (function (_super) {
  12102. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12103. /**
  12104. * Creates a new Vector2WithInfo
  12105. * @param source defines the vector2 data to transport
  12106. * @param buttonIndex defines the current mouse button index
  12107. */
  12108. function Vector2WithInfo(source,
  12109. /** defines the current mouse button index */
  12110. buttonIndex) {
  12111. if (buttonIndex === void 0) { buttonIndex = 0; }
  12112. var _this = _super.call(this, source.x, source.y) || this;
  12113. _this.buttonIndex = buttonIndex;
  12114. return _this;
  12115. }
  12116. return Vector2WithInfo;
  12117. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12118. /** Class used to provide 2D matrix features */
  12119. var Matrix2D = /** @class */ (function () {
  12120. /**
  12121. * Creates a new matrix
  12122. * @param m00 defines value for (0, 0)
  12123. * @param m01 defines value for (0, 1)
  12124. * @param m10 defines value for (1, 0)
  12125. * @param m11 defines value for (1, 1)
  12126. * @param m20 defines value for (2, 0)
  12127. * @param m21 defines value for (2, 1)
  12128. */
  12129. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12130. /** Gets the internal array of 6 floats used to store matrix data */
  12131. this.m = new Float32Array(6);
  12132. this.fromValues(m00, m01, m10, m11, m20, m21);
  12133. }
  12134. /**
  12135. * Fills the matrix from direct values
  12136. * @param m00 defines value for (0, 0)
  12137. * @param m01 defines value for (0, 1)
  12138. * @param m10 defines value for (1, 0)
  12139. * @param m11 defines value for (1, 1)
  12140. * @param m20 defines value for (2, 0)
  12141. * @param m21 defines value for (2, 1)
  12142. * @returns the current modified matrix
  12143. */
  12144. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12145. this.m[0] = m00;
  12146. this.m[1] = m01;
  12147. this.m[2] = m10;
  12148. this.m[3] = m11;
  12149. this.m[4] = m20;
  12150. this.m[5] = m21;
  12151. return this;
  12152. };
  12153. /**
  12154. * Gets matrix determinant
  12155. * @returns the determinant
  12156. */
  12157. Matrix2D.prototype.determinant = function () {
  12158. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12159. };
  12160. /**
  12161. * Inverses the matrix and stores it in a target matrix
  12162. * @param result defines the target matrix
  12163. * @returns the current matrix
  12164. */
  12165. Matrix2D.prototype.invertToRef = function (result) {
  12166. var l0 = this.m[0];
  12167. var l1 = this.m[1];
  12168. var l2 = this.m[2];
  12169. var l3 = this.m[3];
  12170. var l4 = this.m[4];
  12171. var l5 = this.m[5];
  12172. var det = this.determinant();
  12173. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12174. result.m[0] = 0;
  12175. result.m[1] = 0;
  12176. result.m[2] = 0;
  12177. result.m[3] = 0;
  12178. result.m[4] = 0;
  12179. result.m[5] = 0;
  12180. return this;
  12181. }
  12182. var detDiv = 1 / det;
  12183. var det4 = l2 * l5 - l3 * l4;
  12184. var det5 = l1 * l4 - l0 * l5;
  12185. result.m[0] = l3 * detDiv;
  12186. result.m[1] = -l1 * detDiv;
  12187. result.m[2] = -l2 * detDiv;
  12188. result.m[3] = l0 * detDiv;
  12189. result.m[4] = det4 * detDiv;
  12190. result.m[5] = det5 * detDiv;
  12191. return this;
  12192. };
  12193. /**
  12194. * Multiplies the current matrix with another one
  12195. * @param other defines the second operand
  12196. * @param result defines the target matrix
  12197. * @returns the current matrix
  12198. */
  12199. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12200. var l0 = this.m[0];
  12201. var l1 = this.m[1];
  12202. var l2 = this.m[2];
  12203. var l3 = this.m[3];
  12204. var l4 = this.m[4];
  12205. var l5 = this.m[5];
  12206. var r0 = other.m[0];
  12207. var r1 = other.m[1];
  12208. var r2 = other.m[2];
  12209. var r3 = other.m[3];
  12210. var r4 = other.m[4];
  12211. var r5 = other.m[5];
  12212. result.m[0] = l0 * r0 + l1 * r2;
  12213. result.m[1] = l0 * r1 + l1 * r3;
  12214. result.m[2] = l2 * r0 + l3 * r2;
  12215. result.m[3] = l2 * r1 + l3 * r3;
  12216. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12217. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12218. return this;
  12219. };
  12220. /**
  12221. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12222. * @param x defines the x coordinate to transform
  12223. * @param y defines the x coordinate to transform
  12224. * @param result defines the target vector2
  12225. * @returns the current matrix
  12226. */
  12227. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12228. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12229. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12230. return this;
  12231. };
  12232. // Statics
  12233. /**
  12234. * Creates an identity matrix
  12235. * @returns a new matrix
  12236. */
  12237. Matrix2D.Identity = function () {
  12238. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12239. };
  12240. /**
  12241. * Creates a translation matrix and stores it in a target matrix
  12242. * @param x defines the x coordinate of the translation
  12243. * @param y defines the y coordinate of the translation
  12244. * @param result defines the target matrix
  12245. */
  12246. Matrix2D.TranslationToRef = function (x, y, result) {
  12247. result.fromValues(1, 0, 0, 1, x, y);
  12248. };
  12249. /**
  12250. * Creates a scaling matrix and stores it in a target matrix
  12251. * @param x defines the x coordinate of the scaling
  12252. * @param y defines the y coordinate of the scaling
  12253. * @param result defines the target matrix
  12254. */
  12255. Matrix2D.ScalingToRef = function (x, y, result) {
  12256. result.fromValues(x, 0, 0, y, 0, 0);
  12257. };
  12258. /**
  12259. * Creates a rotation matrix and stores it in a target matrix
  12260. * @param angle defines the rotation angle
  12261. * @param result defines the target matrix
  12262. */
  12263. Matrix2D.RotationToRef = function (angle, result) {
  12264. var s = Math.sin(angle);
  12265. var c = Math.cos(angle);
  12266. result.fromValues(c, s, -s, c, 0, 0);
  12267. };
  12268. /**
  12269. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12270. * @param tx defines the x coordinate of the translation
  12271. * @param ty defines the y coordinate of the translation
  12272. * @param angle defines the rotation angle
  12273. * @param scaleX defines the x coordinate of the scaling
  12274. * @param scaleY defines the y coordinate of the scaling
  12275. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12276. * @param result defines the target matrix
  12277. */
  12278. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12279. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12280. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12281. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12282. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12283. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12284. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12285. if (parentMatrix) {
  12286. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12287. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12288. }
  12289. else {
  12290. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12291. }
  12292. };
  12293. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12294. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12295. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12296. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12297. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12298. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12299. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12300. return Matrix2D;
  12301. }());
  12302. /***/ }),
  12303. /***/ "./2D/measure.ts":
  12304. /*!***********************!*\
  12305. !*** ./2D/measure.ts ***!
  12306. \***********************/
  12307. /*! exports provided: Measure */
  12308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12309. "use strict";
  12310. __webpack_require__.r(__webpack_exports__);
  12311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12312. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12313. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12314. /**
  12315. * Class used to store 2D control sizes
  12316. */
  12317. var Measure = /** @class */ (function () {
  12318. /**
  12319. * Creates a new measure
  12320. * @param left defines left coordinate
  12321. * @param top defines top coordinate
  12322. * @param width defines width dimension
  12323. * @param height defines height dimension
  12324. */
  12325. function Measure(
  12326. /** defines left coordinate */
  12327. left,
  12328. /** defines top coordinate */
  12329. top,
  12330. /** defines width dimension */
  12331. width,
  12332. /** defines height dimension */
  12333. height) {
  12334. this.left = left;
  12335. this.top = top;
  12336. this.width = width;
  12337. this.height = height;
  12338. }
  12339. /**
  12340. * Copy from another measure
  12341. * @param other defines the other measure to copy from
  12342. */
  12343. Measure.prototype.copyFrom = function (other) {
  12344. this.left = other.left;
  12345. this.top = other.top;
  12346. this.width = other.width;
  12347. this.height = other.height;
  12348. };
  12349. /**
  12350. * Copy from a group of 4 floats
  12351. * @param left defines left coordinate
  12352. * @param top defines top coordinate
  12353. * @param width defines width dimension
  12354. * @param height defines height dimension
  12355. */
  12356. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12357. this.left = left;
  12358. this.top = top;
  12359. this.width = width;
  12360. this.height = height;
  12361. };
  12362. /**
  12363. * Computes the axis aligned bounding box measure for two given measures
  12364. * @param a Input measure
  12365. * @param b Input measure
  12366. * @param result the resulting bounding measure
  12367. */
  12368. Measure.CombineToRef = function (a, b, result) {
  12369. var left = Math.min(a.left, b.left);
  12370. var top = Math.min(a.top, b.top);
  12371. var right = Math.max(a.left + a.width, b.left + b.width);
  12372. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12373. result.left = left;
  12374. result.top = top;
  12375. result.width = right - left;
  12376. result.height = bottom - top;
  12377. };
  12378. /**
  12379. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12380. * @param transform the matrix to transform the measure before computing the AABB
  12381. * @param result the resulting AABB
  12382. */
  12383. Measure.prototype.transformToRef = function (transform, result) {
  12384. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  12385. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  12386. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12387. for (var i = 0; i < 4; i++) {
  12388. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  12389. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  12390. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  12391. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  12392. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12393. }
  12394. result.left = min.x;
  12395. result.top = min.y;
  12396. result.width = max.x - min.x;
  12397. result.height = max.y - min.y;
  12398. };
  12399. /**
  12400. * Check equality between this measure and another one
  12401. * @param other defines the other measures
  12402. * @returns true if both measures are equals
  12403. */
  12404. Measure.prototype.isEqualsTo = function (other) {
  12405. if (this.left !== other.left) {
  12406. return false;
  12407. }
  12408. if (this.top !== other.top) {
  12409. return false;
  12410. }
  12411. if (this.width !== other.width) {
  12412. return false;
  12413. }
  12414. if (this.height !== other.height) {
  12415. return false;
  12416. }
  12417. return true;
  12418. };
  12419. /**
  12420. * Creates an empty measure
  12421. * @returns a new measure
  12422. */
  12423. Measure.Empty = function () {
  12424. return new Measure(0, 0, 0, 0);
  12425. };
  12426. return Measure;
  12427. }());
  12428. /***/ }),
  12429. /***/ "./2D/multiLinePoint.ts":
  12430. /*!******************************!*\
  12431. !*** ./2D/multiLinePoint.ts ***!
  12432. \******************************/
  12433. /*! exports provided: MultiLinePoint */
  12434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12435. "use strict";
  12436. __webpack_require__.r(__webpack_exports__);
  12437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12438. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12439. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12440. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12441. /**
  12442. * Class used to store a point for a MultiLine object.
  12443. * The point can be pure 2D coordinates, a mesh or a control
  12444. */
  12445. var MultiLinePoint = /** @class */ (function () {
  12446. /**
  12447. * Creates a new MultiLinePoint
  12448. * @param multiLine defines the source MultiLine object
  12449. */
  12450. function MultiLinePoint(multiLine) {
  12451. this._multiLine = multiLine;
  12452. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12453. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12454. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12455. }
  12456. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12457. /** Gets or sets x coordinate */
  12458. get: function () {
  12459. return this._x.toString(this._multiLine._host);
  12460. },
  12461. set: function (value) {
  12462. if (this._x.toString(this._multiLine._host) === value) {
  12463. return;
  12464. }
  12465. if (this._x.fromString(value)) {
  12466. this._multiLine._markAsDirty();
  12467. }
  12468. },
  12469. enumerable: true,
  12470. configurable: true
  12471. });
  12472. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12473. /** Gets or sets y coordinate */
  12474. get: function () {
  12475. return this._y.toString(this._multiLine._host);
  12476. },
  12477. set: function (value) {
  12478. if (this._y.toString(this._multiLine._host) === value) {
  12479. return;
  12480. }
  12481. if (this._y.fromString(value)) {
  12482. this._multiLine._markAsDirty();
  12483. }
  12484. },
  12485. enumerable: true,
  12486. configurable: true
  12487. });
  12488. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12489. /** Gets or sets the control associated with this point */
  12490. get: function () {
  12491. return this._control;
  12492. },
  12493. set: function (value) {
  12494. if (this._control === value) {
  12495. return;
  12496. }
  12497. if (this._control && this._controlObserver) {
  12498. this._control.onDirtyObservable.remove(this._controlObserver);
  12499. this._controlObserver = null;
  12500. }
  12501. this._control = value;
  12502. if (this._control) {
  12503. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12504. }
  12505. this._multiLine._markAsDirty();
  12506. },
  12507. enumerable: true,
  12508. configurable: true
  12509. });
  12510. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12511. /** Gets or sets the mesh associated with this point */
  12512. get: function () {
  12513. return this._mesh;
  12514. },
  12515. set: function (value) {
  12516. if (this._mesh === value) {
  12517. return;
  12518. }
  12519. if (this._mesh && this._meshObserver) {
  12520. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12521. }
  12522. this._mesh = value;
  12523. if (this._mesh) {
  12524. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12525. }
  12526. this._multiLine._markAsDirty();
  12527. },
  12528. enumerable: true,
  12529. configurable: true
  12530. });
  12531. /** Resets links */
  12532. MultiLinePoint.prototype.resetLinks = function () {
  12533. this.control = null;
  12534. this.mesh = null;
  12535. };
  12536. /**
  12537. * Gets a translation vector
  12538. * @returns the translation vector
  12539. */
  12540. MultiLinePoint.prototype.translate = function () {
  12541. this._point = this._translatePoint();
  12542. return this._point;
  12543. };
  12544. MultiLinePoint.prototype._translatePoint = function () {
  12545. if (this._mesh != null) {
  12546. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12547. }
  12548. else if (this._control != null) {
  12549. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12550. }
  12551. else {
  12552. var host = this._multiLine._host;
  12553. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12554. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12555. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12556. }
  12557. };
  12558. /** Release associated resources */
  12559. MultiLinePoint.prototype.dispose = function () {
  12560. this.resetLinks();
  12561. };
  12562. return MultiLinePoint;
  12563. }());
  12564. /***/ }),
  12565. /***/ "./2D/style.ts":
  12566. /*!*********************!*\
  12567. !*** ./2D/style.ts ***!
  12568. \*********************/
  12569. /*! exports provided: Style */
  12570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12571. "use strict";
  12572. __webpack_require__.r(__webpack_exports__);
  12573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12574. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12575. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12576. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12577. /**
  12578. * Define a style used by control to automatically setup properties based on a template.
  12579. * Only support font related properties so far
  12580. */
  12581. var Style = /** @class */ (function () {
  12582. /**
  12583. * Creates a new style object
  12584. * @param host defines the AdvancedDynamicTexture which hosts this style
  12585. */
  12586. function Style(host) {
  12587. this._fontFamily = "Arial";
  12588. this._fontStyle = "";
  12589. this._fontWeight = "";
  12590. /** @hidden */
  12591. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12592. /**
  12593. * Observable raised when the style values are changed
  12594. */
  12595. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12596. this._host = host;
  12597. }
  12598. Object.defineProperty(Style.prototype, "fontSize", {
  12599. /**
  12600. * Gets or sets the font size
  12601. */
  12602. get: function () {
  12603. return this._fontSize.toString(this._host);
  12604. },
  12605. set: function (value) {
  12606. if (this._fontSize.toString(this._host) === value) {
  12607. return;
  12608. }
  12609. if (this._fontSize.fromString(value)) {
  12610. this.onChangedObservable.notifyObservers(this);
  12611. }
  12612. },
  12613. enumerable: true,
  12614. configurable: true
  12615. });
  12616. Object.defineProperty(Style.prototype, "fontFamily", {
  12617. /**
  12618. * Gets or sets the font family
  12619. */
  12620. get: function () {
  12621. return this._fontFamily;
  12622. },
  12623. set: function (value) {
  12624. if (this._fontFamily === value) {
  12625. return;
  12626. }
  12627. this._fontFamily = value;
  12628. this.onChangedObservable.notifyObservers(this);
  12629. },
  12630. enumerable: true,
  12631. configurable: true
  12632. });
  12633. Object.defineProperty(Style.prototype, "fontStyle", {
  12634. /**
  12635. * Gets or sets the font style
  12636. */
  12637. get: function () {
  12638. return this._fontStyle;
  12639. },
  12640. set: function (value) {
  12641. if (this._fontStyle === value) {
  12642. return;
  12643. }
  12644. this._fontStyle = value;
  12645. this.onChangedObservable.notifyObservers(this);
  12646. },
  12647. enumerable: true,
  12648. configurable: true
  12649. });
  12650. Object.defineProperty(Style.prototype, "fontWeight", {
  12651. /** Gets or sets font weight */
  12652. get: function () {
  12653. return this._fontWeight;
  12654. },
  12655. set: function (value) {
  12656. if (this._fontWeight === value) {
  12657. return;
  12658. }
  12659. this._fontWeight = value;
  12660. this.onChangedObservable.notifyObservers(this);
  12661. },
  12662. enumerable: true,
  12663. configurable: true
  12664. });
  12665. /** Dispose all associated resources */
  12666. Style.prototype.dispose = function () {
  12667. this.onChangedObservable.clear();
  12668. };
  12669. return Style;
  12670. }());
  12671. /***/ }),
  12672. /***/ "./2D/valueAndUnit.ts":
  12673. /*!****************************!*\
  12674. !*** ./2D/valueAndUnit.ts ***!
  12675. \****************************/
  12676. /*! exports provided: ValueAndUnit */
  12677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12678. "use strict";
  12679. __webpack_require__.r(__webpack_exports__);
  12680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12681. /**
  12682. * Class used to specific a value and its associated unit
  12683. */
  12684. var ValueAndUnit = /** @class */ (function () {
  12685. /**
  12686. * Creates a new ValueAndUnit
  12687. * @param value defines the value to store
  12688. * @param unit defines the unit to store
  12689. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12690. */
  12691. function ValueAndUnit(value,
  12692. /** defines the unit to store */
  12693. unit,
  12694. /** defines a boolean indicating if the value can be negative */
  12695. negativeValueAllowed) {
  12696. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12697. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12698. this.unit = unit;
  12699. this.negativeValueAllowed = negativeValueAllowed;
  12700. this._value = 1;
  12701. /**
  12702. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12703. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12704. */
  12705. this.ignoreAdaptiveScaling = false;
  12706. this._value = value;
  12707. this._originalUnit = unit;
  12708. }
  12709. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12710. /** Gets a boolean indicating if the value is a percentage */
  12711. get: function () {
  12712. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12713. },
  12714. enumerable: true,
  12715. configurable: true
  12716. });
  12717. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12718. /** Gets a boolean indicating if the value is store as pixel */
  12719. get: function () {
  12720. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12721. },
  12722. enumerable: true,
  12723. configurable: true
  12724. });
  12725. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12726. /** Gets direct internal value */
  12727. get: function () {
  12728. return this._value;
  12729. },
  12730. enumerable: true,
  12731. configurable: true
  12732. });
  12733. /**
  12734. * Gets value as pixel
  12735. * @param host defines the root host
  12736. * @param refValue defines the reference value for percentages
  12737. * @returns the value as pixel
  12738. */
  12739. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12740. if (this.isPixel) {
  12741. return this.getValue(host);
  12742. }
  12743. return this.getValue(host) * refValue;
  12744. };
  12745. /**
  12746. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12747. * @param value defines the value to store
  12748. * @param unit defines the unit to store
  12749. * @returns the current ValueAndUnit
  12750. */
  12751. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12752. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12753. this._value = value;
  12754. this.unit = unit;
  12755. return this;
  12756. };
  12757. /**
  12758. * Gets the value accordingly to its unit
  12759. * @param host defines the root host
  12760. * @returns the value
  12761. */
  12762. ValueAndUnit.prototype.getValue = function (host) {
  12763. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12764. var width = 0;
  12765. var height = 0;
  12766. if (host.idealWidth) {
  12767. width = (this._value * host.getSize().width) / host.idealWidth;
  12768. }
  12769. if (host.idealHeight) {
  12770. height = (this._value * host.getSize().height) / host.idealHeight;
  12771. }
  12772. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12773. return window.innerWidth < window.innerHeight ? width : height;
  12774. }
  12775. if (host.idealWidth) { // horizontal
  12776. return width;
  12777. }
  12778. if (host.idealHeight) { // vertical
  12779. return height;
  12780. }
  12781. }
  12782. return this._value;
  12783. };
  12784. /**
  12785. * Gets a string representation of the value
  12786. * @param host defines the root host
  12787. * @param decimals defines an optional number of decimals to display
  12788. * @returns a string
  12789. */
  12790. ValueAndUnit.prototype.toString = function (host, decimals) {
  12791. switch (this.unit) {
  12792. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12793. var percentage = this.getValue(host) * 100;
  12794. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12795. case ValueAndUnit.UNITMODE_PIXEL:
  12796. var pixels = this.getValue(host);
  12797. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12798. }
  12799. return this.unit.toString();
  12800. };
  12801. /**
  12802. * Store a value parsed from a string
  12803. * @param source defines the source string
  12804. * @returns true if the value was successfully parsed
  12805. */
  12806. ValueAndUnit.prototype.fromString = function (source) {
  12807. var match = ValueAndUnit._Regex.exec(source.toString());
  12808. if (!match || match.length === 0) {
  12809. return false;
  12810. }
  12811. var sourceValue = parseFloat(match[1]);
  12812. var sourceUnit = this._originalUnit;
  12813. if (!this.negativeValueAllowed) {
  12814. if (sourceValue < 0) {
  12815. sourceValue = 0;
  12816. }
  12817. }
  12818. if (match.length === 4) {
  12819. switch (match[3]) {
  12820. case "px":
  12821. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12822. break;
  12823. case "%":
  12824. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12825. sourceValue /= 100.0;
  12826. break;
  12827. }
  12828. }
  12829. if (sourceValue === this._value && sourceUnit === this.unit) {
  12830. return false;
  12831. }
  12832. this._value = sourceValue;
  12833. this.unit = sourceUnit;
  12834. return true;
  12835. };
  12836. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12837. /** UNITMODE_PERCENTAGE */
  12838. get: function () {
  12839. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12840. },
  12841. enumerable: true,
  12842. configurable: true
  12843. });
  12844. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12845. /** UNITMODE_PIXEL */
  12846. get: function () {
  12847. return ValueAndUnit._UNITMODE_PIXEL;
  12848. },
  12849. enumerable: true,
  12850. configurable: true
  12851. });
  12852. // Static
  12853. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12854. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12855. ValueAndUnit._UNITMODE_PIXEL = 1;
  12856. return ValueAndUnit;
  12857. }());
  12858. /***/ }),
  12859. /***/ "./2D/xmlLoader.ts":
  12860. /*!*************************!*\
  12861. !*** ./2D/xmlLoader.ts ***!
  12862. \*************************/
  12863. /*! exports provided: XmlLoader */
  12864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12865. "use strict";
  12866. __webpack_require__.r(__webpack_exports__);
  12867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  12868. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  12869. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  12870. /**
  12871. * Class used to load GUI via XML.
  12872. */
  12873. var XmlLoader = /** @class */ (function () {
  12874. /**
  12875. * Create a new xml loader
  12876. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  12877. */
  12878. function XmlLoader(parentClass) {
  12879. if (parentClass === void 0) { parentClass = null; }
  12880. this._nodes = {};
  12881. this._nodeTypes = {
  12882. element: 1,
  12883. attribute: 2,
  12884. text: 3
  12885. };
  12886. this._isLoaded = false;
  12887. this._objectAttributes = {
  12888. "textHorizontalAlignment": 1,
  12889. "textVerticalAlignment": 2,
  12890. "horizontalAlignment": 3,
  12891. "verticalAlignment": 4,
  12892. "stretch": 5,
  12893. };
  12894. if (parentClass) {
  12895. this._parentClass = parentClass;
  12896. }
  12897. }
  12898. XmlLoader.prototype._getChainElement = function (attributeValue) {
  12899. var element = window;
  12900. if (this._parentClass) {
  12901. element = this._parentClass;
  12902. }
  12903. var value = attributeValue;
  12904. value = value.split(".");
  12905. for (var i = 0; i < value.length; i++) {
  12906. element = element[value[i]];
  12907. }
  12908. return element;
  12909. };
  12910. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  12911. var attribute = attributeName.split(".");
  12912. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  12913. return className[attribute[1]];
  12914. };
  12915. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  12916. if (linkParent === void 0) { linkParent = true; }
  12917. try {
  12918. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  12919. var guiNode = new className();
  12920. if (parent && linkParent) {
  12921. parent.addControl(guiNode);
  12922. }
  12923. for (var i = 0; i < node.attributes.length; i++) {
  12924. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  12925. continue;
  12926. }
  12927. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  12928. var element = this._getChainElement(node.attributes[i].value);
  12929. guiNode[node.attributes[i].name].add(element);
  12930. continue;
  12931. }
  12932. else if (node.attributes[i].name == "linkWithMesh") {
  12933. if (this._parentClass) {
  12934. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  12935. }
  12936. else {
  12937. guiNode.linkWithMesh(window[node.attributes[i].value]);
  12938. }
  12939. }
  12940. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  12941. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  12942. guiNode[node.attributes[i].name] = element;
  12943. }
  12944. else if (!this._objectAttributes[node.attributes[i].name]) {
  12945. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  12946. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  12947. }
  12948. else {
  12949. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  12950. }
  12951. }
  12952. else {
  12953. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  12954. }
  12955. }
  12956. if (!node.attributes.getNamedItem("id")) {
  12957. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  12958. return guiNode;
  12959. }
  12960. var id = node.attributes.getNamedItem("id").value;
  12961. if (id.startsWith("{{") && id.endsWith("}}")) {
  12962. id = this._getChainElement(id.substring(2, id.length - 2));
  12963. }
  12964. if (!this._nodes[id]) {
  12965. this._nodes[id] = guiNode;
  12966. }
  12967. else {
  12968. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  12969. }
  12970. return guiNode;
  12971. }
  12972. catch (e) {
  12973. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  12974. }
  12975. };
  12976. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  12977. var width;
  12978. var height;
  12979. var columns;
  12980. var rows = node.children;
  12981. var cells;
  12982. var isPixel = false;
  12983. var cellNode;
  12984. var rowNumber = -1;
  12985. var columnNumber = -1;
  12986. var totalColumnsNumber = 0;
  12987. for (var i = 0; i < rows.length; i++) {
  12988. if (rows[i].nodeType != this._nodeTypes.element) {
  12989. continue;
  12990. }
  12991. if (rows[i].nodeName != "Row") {
  12992. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  12993. }
  12994. rowNumber += 1;
  12995. columns = rows[i].children;
  12996. if (!rows[i].attributes.getNamedItem("height")) {
  12997. throw "XmlLoader Exception : Height must be defined for grid rows";
  12998. }
  12999. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13000. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13001. guiNode.addRowDefinition(height, isPixel);
  13002. for (var j = 0; j < columns.length; j++) {
  13003. if (columns[j].nodeType != this._nodeTypes.element) {
  13004. continue;
  13005. }
  13006. if (columns[j].nodeName != "Column") {
  13007. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13008. }
  13009. columnNumber += 1;
  13010. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13011. 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.";
  13012. }
  13013. if (rowNumber == 0) {
  13014. if (!columns[j].attributes.getNamedItem("width")) {
  13015. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13016. }
  13017. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13018. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13019. guiNode.addColumnDefinition(width, isPixel);
  13020. }
  13021. cells = columns[j].children;
  13022. for (var k = 0; k < cells.length; k++) {
  13023. if (cells[k].nodeType != this._nodeTypes.element) {
  13024. continue;
  13025. }
  13026. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13027. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13028. if (cells[k].firstChild) {
  13029. this._parseXml(cells[k].firstChild, cellNode);
  13030. }
  13031. }
  13032. }
  13033. if (rowNumber == 0) {
  13034. totalColumnsNumber = columnNumber;
  13035. }
  13036. columnNumber = -1;
  13037. }
  13038. if (node.nextSibling) {
  13039. this._parseXml(node.nextSibling, parent);
  13040. }
  13041. };
  13042. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13043. if (node.firstChild) {
  13044. this._parseXml(node.firstChild, guiNode);
  13045. }
  13046. if (node.nextSibling) {
  13047. this._parseXml(node.nextSibling, parent);
  13048. }
  13049. };
  13050. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13051. if (this._parentClass) {
  13052. this._parentClass[variable] = source[iterator];
  13053. }
  13054. else {
  13055. window[variable] = source[iterator];
  13056. }
  13057. if (node.firstChild) {
  13058. this._parseXml(node.firstChild, guiNode, true);
  13059. }
  13060. };
  13061. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13062. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13063. if (!dataSource.includes(" in ")) {
  13064. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13065. }
  13066. else {
  13067. var isArray = true;
  13068. var splittedSource = dataSource.split(" in ");
  13069. if (splittedSource.length < 2) {
  13070. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13071. }
  13072. var source = splittedSource[1];
  13073. if (source.startsWith("{") && source.endsWith("}")) {
  13074. isArray = false;
  13075. }
  13076. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13077. source = source.substring(1, source.length - 1);
  13078. }
  13079. if (this._parentClass) {
  13080. source = this._parentClass[source];
  13081. }
  13082. else {
  13083. source = window[source];
  13084. }
  13085. if (isArray) {
  13086. for (var i = 0; i < source.length; i++) {
  13087. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13088. }
  13089. }
  13090. else {
  13091. for (var i in source) {
  13092. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13093. }
  13094. }
  13095. if (node.nextSibling) {
  13096. this._parseXml(node.nextSibling, parent);
  13097. }
  13098. }
  13099. };
  13100. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13101. if (generated === void 0) { generated = false; }
  13102. if (node.nodeType != this._nodeTypes.element) {
  13103. if (node.nextSibling) {
  13104. this._parseXml(node.nextSibling, parent, generated);
  13105. }
  13106. return;
  13107. }
  13108. if (generated) {
  13109. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13110. }
  13111. var guiNode = this._createGuiElement(node, parent);
  13112. if (node.nodeName == "Grid") {
  13113. this._parseGrid(node, guiNode, parent);
  13114. }
  13115. else if (!node.attributes.getNamedItem("dataSource")) {
  13116. this._parseElement(node, guiNode, parent);
  13117. }
  13118. else {
  13119. this._parseElementsFromSource(node, guiNode, parent);
  13120. }
  13121. };
  13122. /**
  13123. * Gets if the loading has finished.
  13124. * @returns whether the loading has finished or not
  13125. */
  13126. XmlLoader.prototype.isLoaded = function () {
  13127. return this._isLoaded;
  13128. };
  13129. /**
  13130. * Gets a loaded node / control by id.
  13131. * @param id the Controls id set in the xml
  13132. * @returns element of type Control
  13133. */
  13134. XmlLoader.prototype.getNodeById = function (id) {
  13135. return this._nodes[id];
  13136. };
  13137. /**
  13138. * Gets all loaded nodes / controls
  13139. * @returns Array of controls
  13140. */
  13141. XmlLoader.prototype.getNodes = function () {
  13142. return this._nodes;
  13143. };
  13144. /**
  13145. * Initiates the xml layout loading
  13146. * @param xmlFile defines the xml layout to load
  13147. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13148. * @param callback defines the callback called on layout load.
  13149. */
  13150. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13151. var xhttp = new XMLHttpRequest();
  13152. xhttp.onreadystatechange = function () {
  13153. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13154. if (!xhttp.responseXML) {
  13155. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13156. }
  13157. var xmlDoc = xhttp.responseXML.documentElement;
  13158. this._parseXml(xmlDoc.firstChild, rootNode);
  13159. this._isLoaded = true;
  13160. if (callback) {
  13161. callback();
  13162. }
  13163. }
  13164. }.bind(this);
  13165. xhttp.open("GET", xmlFile, true);
  13166. xhttp.send();
  13167. };
  13168. return XmlLoader;
  13169. }());
  13170. /***/ }),
  13171. /***/ "./3D/controls/abstractButton3D.ts":
  13172. /*!*****************************************!*\
  13173. !*** ./3D/controls/abstractButton3D.ts ***!
  13174. \*****************************************/
  13175. /*! exports provided: AbstractButton3D */
  13176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13177. "use strict";
  13178. __webpack_require__.r(__webpack_exports__);
  13179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13180. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13181. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13182. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13183. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13184. /**
  13185. * Class used as a root to all buttons
  13186. */
  13187. var AbstractButton3D = /** @class */ (function (_super) {
  13188. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13189. /**
  13190. * Creates a new button
  13191. * @param name defines the control name
  13192. */
  13193. function AbstractButton3D(name) {
  13194. return _super.call(this, name) || this;
  13195. }
  13196. AbstractButton3D.prototype._getTypeName = function () {
  13197. return "AbstractButton3D";
  13198. };
  13199. // Mesh association
  13200. AbstractButton3D.prototype._createNode = function (scene) {
  13201. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13202. };
  13203. return AbstractButton3D;
  13204. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13205. /***/ }),
  13206. /***/ "./3D/controls/button3D.ts":
  13207. /*!*********************************!*\
  13208. !*** ./3D/controls/button3D.ts ***!
  13209. \*********************************/
  13210. /*! exports provided: Button3D */
  13211. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13212. "use strict";
  13213. __webpack_require__.r(__webpack_exports__);
  13214. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13215. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13216. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13217. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13218. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13219. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13220. /**
  13221. * Class used to create a button in 3D
  13222. */
  13223. var Button3D = /** @class */ (function (_super) {
  13224. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13225. /**
  13226. * Creates a new button
  13227. * @param name defines the control name
  13228. */
  13229. function Button3D(name) {
  13230. var _this = _super.call(this, name) || this;
  13231. _this._contentResolution = 512;
  13232. _this._contentScaleRatio = 2;
  13233. // Default animations
  13234. _this.pointerEnterAnimation = function () {
  13235. if (!_this.mesh) {
  13236. return;
  13237. }
  13238. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13239. };
  13240. _this.pointerOutAnimation = function () {
  13241. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13242. };
  13243. _this.pointerDownAnimation = function () {
  13244. if (!_this.mesh) {
  13245. return;
  13246. }
  13247. _this.mesh.scaling.scaleInPlace(0.95);
  13248. };
  13249. _this.pointerUpAnimation = function () {
  13250. if (!_this.mesh) {
  13251. return;
  13252. }
  13253. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13254. };
  13255. return _this;
  13256. }
  13257. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13258. /**
  13259. * Gets or sets the texture resolution used to render content (512 by default)
  13260. */
  13261. get: function () {
  13262. return this._contentResolution;
  13263. },
  13264. set: function (value) {
  13265. if (this._contentResolution === value) {
  13266. return;
  13267. }
  13268. this._contentResolution = value;
  13269. this._resetContent();
  13270. },
  13271. enumerable: true,
  13272. configurable: true
  13273. });
  13274. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13275. /**
  13276. * Gets or sets the texture scale ratio used to render content (2 by default)
  13277. */
  13278. get: function () {
  13279. return this._contentScaleRatio;
  13280. },
  13281. set: function (value) {
  13282. if (this._contentScaleRatio === value) {
  13283. return;
  13284. }
  13285. this._contentScaleRatio = value;
  13286. this._resetContent();
  13287. },
  13288. enumerable: true,
  13289. configurable: true
  13290. });
  13291. Button3D.prototype._disposeFacadeTexture = function () {
  13292. if (this._facadeTexture) {
  13293. this._facadeTexture.dispose();
  13294. this._facadeTexture = null;
  13295. }
  13296. };
  13297. Button3D.prototype._resetContent = function () {
  13298. this._disposeFacadeTexture();
  13299. this.content = this._content;
  13300. };
  13301. Object.defineProperty(Button3D.prototype, "content", {
  13302. /**
  13303. * Gets or sets the GUI 2D content used to display the button's facade
  13304. */
  13305. get: function () {
  13306. return this._content;
  13307. },
  13308. set: function (value) {
  13309. this._content = value;
  13310. if (!this._host || !this._host.utilityLayer) {
  13311. return;
  13312. }
  13313. if (!this._facadeTexture) {
  13314. 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);
  13315. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13316. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13317. this._facadeTexture.premulAlpha = true;
  13318. }
  13319. else {
  13320. this._facadeTexture.rootContainer.clearControls();
  13321. }
  13322. this._facadeTexture.addControl(value);
  13323. this._applyFacade(this._facadeTexture);
  13324. },
  13325. enumerable: true,
  13326. configurable: true
  13327. });
  13328. /**
  13329. * Apply the facade texture (created from the content property).
  13330. * This function can be overloaded by child classes
  13331. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13332. */
  13333. Button3D.prototype._applyFacade = function (facadeTexture) {
  13334. this._currentMaterial.emissiveTexture = facadeTexture;
  13335. };
  13336. Button3D.prototype._getTypeName = function () {
  13337. return "Button3D";
  13338. };
  13339. // Mesh association
  13340. Button3D.prototype._createNode = function (scene) {
  13341. var faceUV = new Array(6);
  13342. for (var i = 0; i < 6; i++) {
  13343. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13344. }
  13345. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13346. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13347. width: 1.0,
  13348. height: 1.0,
  13349. depth: 0.08,
  13350. faceUV: faceUV
  13351. }, scene);
  13352. return mesh;
  13353. };
  13354. Button3D.prototype._affectMaterial = function (mesh) {
  13355. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13356. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13357. mesh.material = material;
  13358. this._currentMaterial = material;
  13359. this._resetContent();
  13360. };
  13361. /**
  13362. * Releases all associated resources
  13363. */
  13364. Button3D.prototype.dispose = function () {
  13365. _super.prototype.dispose.call(this);
  13366. this._disposeFacadeTexture();
  13367. if (this._currentMaterial) {
  13368. this._currentMaterial.dispose();
  13369. }
  13370. };
  13371. return Button3D;
  13372. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13373. /***/ }),
  13374. /***/ "./3D/controls/container3D.ts":
  13375. /*!************************************!*\
  13376. !*** ./3D/controls/container3D.ts ***!
  13377. \************************************/
  13378. /*! exports provided: Container3D */
  13379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13380. "use strict";
  13381. __webpack_require__.r(__webpack_exports__);
  13382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13383. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13384. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13385. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13386. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13387. /**
  13388. * Class used to create containers for controls
  13389. */
  13390. var Container3D = /** @class */ (function (_super) {
  13391. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13392. /**
  13393. * Creates a new container
  13394. * @param name defines the container name
  13395. */
  13396. function Container3D(name) {
  13397. var _this = _super.call(this, name) || this;
  13398. _this._blockLayout = false;
  13399. /**
  13400. * Gets the list of child controls
  13401. */
  13402. _this._children = new Array();
  13403. return _this;
  13404. }
  13405. Object.defineProperty(Container3D.prototype, "children", {
  13406. /**
  13407. * Gets the list of child controls
  13408. */
  13409. get: function () {
  13410. return this._children;
  13411. },
  13412. enumerable: true,
  13413. configurable: true
  13414. });
  13415. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13416. /**
  13417. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13418. * This is helpful to optimize layout operation when adding multiple children in a row
  13419. */
  13420. get: function () {
  13421. return this._blockLayout;
  13422. },
  13423. set: function (value) {
  13424. if (this._blockLayout === value) {
  13425. return;
  13426. }
  13427. this._blockLayout = value;
  13428. if (!this._blockLayout) {
  13429. this._arrangeChildren();
  13430. }
  13431. },
  13432. enumerable: true,
  13433. configurable: true
  13434. });
  13435. /**
  13436. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13437. * @returns the current container
  13438. */
  13439. Container3D.prototype.updateLayout = function () {
  13440. this._arrangeChildren();
  13441. return this;
  13442. };
  13443. /**
  13444. * Gets a boolean indicating if the given control is in the children of this control
  13445. * @param control defines the control to check
  13446. * @returns true if the control is in the child list
  13447. */
  13448. Container3D.prototype.containsControl = function (control) {
  13449. return this._children.indexOf(control) !== -1;
  13450. };
  13451. /**
  13452. * Adds a control to the children of this control
  13453. * @param control defines the control to add
  13454. * @returns the current container
  13455. */
  13456. Container3D.prototype.addControl = function (control) {
  13457. var index = this._children.indexOf(control);
  13458. if (index !== -1) {
  13459. return this;
  13460. }
  13461. control.parent = this;
  13462. control._host = this._host;
  13463. this._children.push(control);
  13464. if (this._host.utilityLayer) {
  13465. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13466. if (control.node) {
  13467. control.node.parent = this.node;
  13468. }
  13469. if (!this.blockLayout) {
  13470. this._arrangeChildren();
  13471. }
  13472. }
  13473. return this;
  13474. };
  13475. /**
  13476. * This function will be called everytime a new control is added
  13477. */
  13478. Container3D.prototype._arrangeChildren = function () {
  13479. };
  13480. Container3D.prototype._createNode = function (scene) {
  13481. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13482. };
  13483. /**
  13484. * Removes a control from the children of this control
  13485. * @param control defines the control to remove
  13486. * @returns the current container
  13487. */
  13488. Container3D.prototype.removeControl = function (control) {
  13489. var index = this._children.indexOf(control);
  13490. if (index !== -1) {
  13491. this._children.splice(index, 1);
  13492. control.parent = null;
  13493. control._disposeNode();
  13494. }
  13495. return this;
  13496. };
  13497. Container3D.prototype._getTypeName = function () {
  13498. return "Container3D";
  13499. };
  13500. /**
  13501. * Releases all associated resources
  13502. */
  13503. Container3D.prototype.dispose = function () {
  13504. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13505. var control = _a[_i];
  13506. control.dispose();
  13507. }
  13508. this._children = [];
  13509. _super.prototype.dispose.call(this);
  13510. };
  13511. /** Control rotation will remain unchanged */
  13512. Container3D.UNSET_ORIENTATION = 0;
  13513. /** Control will rotate to make it look at sphere central axis */
  13514. Container3D.FACEORIGIN_ORIENTATION = 1;
  13515. /** Control will rotate to make it look back at sphere central axis */
  13516. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13517. /** Control will rotate to look at z axis (0, 0, 1) */
  13518. Container3D.FACEFORWARD_ORIENTATION = 3;
  13519. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13520. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13521. return Container3D;
  13522. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13523. /***/ }),
  13524. /***/ "./3D/controls/control3D.ts":
  13525. /*!**********************************!*\
  13526. !*** ./3D/controls/control3D.ts ***!
  13527. \**********************************/
  13528. /*! exports provided: Control3D */
  13529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13530. "use strict";
  13531. __webpack_require__.r(__webpack_exports__);
  13532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13533. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  13534. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13535. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13536. /**
  13537. * Class used as base class for controls
  13538. */
  13539. var Control3D = /** @class */ (function () {
  13540. /**
  13541. * Creates a new control
  13542. * @param name defines the control name
  13543. */
  13544. function Control3D(
  13545. /** Defines the control name */
  13546. name) {
  13547. this.name = name;
  13548. this._downCount = 0;
  13549. this._enterCount = -1;
  13550. this._downPointerIds = {};
  13551. this._isVisible = true;
  13552. /**
  13553. * An event triggered when the pointer move over the control
  13554. */
  13555. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13556. /**
  13557. * An event triggered when the pointer move out of the control
  13558. */
  13559. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13560. /**
  13561. * An event triggered when the pointer taps the control
  13562. */
  13563. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13564. /**
  13565. * An event triggered when pointer is up
  13566. */
  13567. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13568. /**
  13569. * An event triggered when a control is clicked on (with a mouse)
  13570. */
  13571. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13572. /**
  13573. * An event triggered when pointer enters the control
  13574. */
  13575. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13576. // Behaviors
  13577. this._behaviors = new Array();
  13578. }
  13579. Object.defineProperty(Control3D.prototype, "position", {
  13580. /** Gets or sets the control position in world space */
  13581. get: function () {
  13582. if (!this._node) {
  13583. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13584. }
  13585. return this._node.position;
  13586. },
  13587. set: function (value) {
  13588. if (!this._node) {
  13589. return;
  13590. }
  13591. this._node.position = value;
  13592. },
  13593. enumerable: true,
  13594. configurable: true
  13595. });
  13596. Object.defineProperty(Control3D.prototype, "scaling", {
  13597. /** Gets or sets the control scaling in world space */
  13598. get: function () {
  13599. if (!this._node) {
  13600. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13601. }
  13602. return this._node.scaling;
  13603. },
  13604. set: function (value) {
  13605. if (!this._node) {
  13606. return;
  13607. }
  13608. this._node.scaling = value;
  13609. },
  13610. enumerable: true,
  13611. configurable: true
  13612. });
  13613. Object.defineProperty(Control3D.prototype, "behaviors", {
  13614. /**
  13615. * Gets the list of attached behaviors
  13616. * @see http://doc.babylonjs.com/features/behaviour
  13617. */
  13618. get: function () {
  13619. return this._behaviors;
  13620. },
  13621. enumerable: true,
  13622. configurable: true
  13623. });
  13624. /**
  13625. * Attach a behavior to the control
  13626. * @see http://doc.babylonjs.com/features/behaviour
  13627. * @param behavior defines the behavior to attach
  13628. * @returns the current control
  13629. */
  13630. Control3D.prototype.addBehavior = function (behavior) {
  13631. var _this = this;
  13632. var index = this._behaviors.indexOf(behavior);
  13633. if (index !== -1) {
  13634. return this;
  13635. }
  13636. behavior.init();
  13637. var scene = this._host.scene;
  13638. if (scene.isLoading) {
  13639. // We defer the attach when the scene will be loaded
  13640. scene.onDataLoadedObservable.addOnce(function () {
  13641. behavior.attach(_this);
  13642. });
  13643. }
  13644. else {
  13645. behavior.attach(this);
  13646. }
  13647. this._behaviors.push(behavior);
  13648. return this;
  13649. };
  13650. /**
  13651. * Remove an attached behavior
  13652. * @see http://doc.babylonjs.com/features/behaviour
  13653. * @param behavior defines the behavior to attach
  13654. * @returns the current control
  13655. */
  13656. Control3D.prototype.removeBehavior = function (behavior) {
  13657. var index = this._behaviors.indexOf(behavior);
  13658. if (index === -1) {
  13659. return this;
  13660. }
  13661. this._behaviors[index].detach();
  13662. this._behaviors.splice(index, 1);
  13663. return this;
  13664. };
  13665. /**
  13666. * Gets an attached behavior by name
  13667. * @param name defines the name of the behavior to look for
  13668. * @see http://doc.babylonjs.com/features/behaviour
  13669. * @returns null if behavior was not found else the requested behavior
  13670. */
  13671. Control3D.prototype.getBehaviorByName = function (name) {
  13672. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13673. var behavior = _a[_i];
  13674. if (behavior.name === name) {
  13675. return behavior;
  13676. }
  13677. }
  13678. return null;
  13679. };
  13680. Object.defineProperty(Control3D.prototype, "isVisible", {
  13681. /** Gets or sets a boolean indicating if the control is visible */
  13682. get: function () {
  13683. return this._isVisible;
  13684. },
  13685. set: function (value) {
  13686. if (this._isVisible === value) {
  13687. return;
  13688. }
  13689. this._isVisible = value;
  13690. var mesh = this.mesh;
  13691. if (mesh) {
  13692. mesh.setEnabled(value);
  13693. }
  13694. },
  13695. enumerable: true,
  13696. configurable: true
  13697. });
  13698. Object.defineProperty(Control3D.prototype, "typeName", {
  13699. /**
  13700. * Gets a string representing the class name
  13701. */
  13702. get: function () {
  13703. return this._getTypeName();
  13704. },
  13705. enumerable: true,
  13706. configurable: true
  13707. });
  13708. /**
  13709. * Get the current class name of the control.
  13710. * @returns current class name
  13711. */
  13712. Control3D.prototype.getClassName = function () {
  13713. return this._getTypeName();
  13714. };
  13715. Control3D.prototype._getTypeName = function () {
  13716. return "Control3D";
  13717. };
  13718. Object.defineProperty(Control3D.prototype, "node", {
  13719. /**
  13720. * Gets the transform node used by this control
  13721. */
  13722. get: function () {
  13723. return this._node;
  13724. },
  13725. enumerable: true,
  13726. configurable: true
  13727. });
  13728. Object.defineProperty(Control3D.prototype, "mesh", {
  13729. /**
  13730. * Gets the mesh used to render this control
  13731. */
  13732. get: function () {
  13733. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13734. return this._node;
  13735. }
  13736. return null;
  13737. },
  13738. enumerable: true,
  13739. configurable: true
  13740. });
  13741. /**
  13742. * Link the control as child of the given node
  13743. * @param node defines the node to link to. Use null to unlink the control
  13744. * @returns the current control
  13745. */
  13746. Control3D.prototype.linkToTransformNode = function (node) {
  13747. if (this._node) {
  13748. this._node.parent = node;
  13749. }
  13750. return this;
  13751. };
  13752. /** @hidden **/
  13753. Control3D.prototype._prepareNode = function (scene) {
  13754. if (!this._node) {
  13755. this._node = this._createNode(scene);
  13756. if (!this.node) {
  13757. return;
  13758. }
  13759. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13760. this._node.position = this.position;
  13761. this._node.scaling = this.scaling;
  13762. var mesh = this.mesh;
  13763. if (mesh) {
  13764. mesh.isPickable = true;
  13765. this._affectMaterial(mesh);
  13766. }
  13767. }
  13768. };
  13769. /**
  13770. * Node creation.
  13771. * Can be overriden by children
  13772. * @param scene defines the scene where the node must be attached
  13773. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13774. */
  13775. Control3D.prototype._createNode = function (scene) {
  13776. // Do nothing by default
  13777. return null;
  13778. };
  13779. /**
  13780. * Affect a material to the given mesh
  13781. * @param mesh defines the mesh which will represent the control
  13782. */
  13783. Control3D.prototype._affectMaterial = function (mesh) {
  13784. mesh.material = null;
  13785. };
  13786. // Pointers
  13787. /** @hidden */
  13788. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13789. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13790. };
  13791. /** @hidden */
  13792. Control3D.prototype._onPointerEnter = function (target) {
  13793. if (this._enterCount > 0) {
  13794. return false;
  13795. }
  13796. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13797. this._enterCount = 0;
  13798. }
  13799. this._enterCount++;
  13800. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13801. if (this.pointerEnterAnimation) {
  13802. this.pointerEnterAnimation();
  13803. }
  13804. return true;
  13805. };
  13806. /** @hidden */
  13807. Control3D.prototype._onPointerOut = function (target) {
  13808. this._enterCount = 0;
  13809. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13810. if (this.pointerOutAnimation) {
  13811. this.pointerOutAnimation();
  13812. }
  13813. };
  13814. /** @hidden */
  13815. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13816. if (this._downCount !== 0) {
  13817. this._downCount++;
  13818. return false;
  13819. }
  13820. this._downCount++;
  13821. this._downPointerIds[pointerId] = true;
  13822. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13823. if (this.pointerDownAnimation) {
  13824. this.pointerDownAnimation();
  13825. }
  13826. return true;
  13827. };
  13828. /** @hidden */
  13829. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13830. this._downCount--;
  13831. delete this._downPointerIds[pointerId];
  13832. if (this._downCount < 0) {
  13833. // Handle if forcePointerUp was called prior to this
  13834. this._downCount = 0;
  13835. return;
  13836. }
  13837. if (this._downCount == 0) {
  13838. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13839. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13840. }
  13841. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13842. if (this.pointerUpAnimation) {
  13843. this.pointerUpAnimation();
  13844. }
  13845. }
  13846. };
  13847. /** @hidden */
  13848. Control3D.prototype.forcePointerUp = function (pointerId) {
  13849. if (pointerId === void 0) { pointerId = null; }
  13850. if (pointerId !== null) {
  13851. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13852. }
  13853. else {
  13854. for (var key in this._downPointerIds) {
  13855. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13856. }
  13857. if (this._downCount > 0) {
  13858. this._downCount = 1;
  13859. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13860. }
  13861. }
  13862. };
  13863. /** @hidden */
  13864. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13865. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13866. this._onPointerMove(this, pickedPoint);
  13867. var previousControlOver = this._host._lastControlOver[pointerId];
  13868. if (previousControlOver && previousControlOver !== this) {
  13869. previousControlOver._onPointerOut(this);
  13870. }
  13871. if (previousControlOver !== this) {
  13872. this._onPointerEnter(this);
  13873. }
  13874. this._host._lastControlOver[pointerId] = this;
  13875. return true;
  13876. }
  13877. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13878. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13879. this._host._lastControlDown[pointerId] = this;
  13880. this._host._lastPickedControl = this;
  13881. return true;
  13882. }
  13883. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13884. if (this._host._lastControlDown[pointerId]) {
  13885. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13886. }
  13887. delete this._host._lastControlDown[pointerId];
  13888. return true;
  13889. }
  13890. return false;
  13891. };
  13892. /** @hidden */
  13893. Control3D.prototype._disposeNode = function () {
  13894. if (this._node) {
  13895. this._node.dispose();
  13896. this._node = null;
  13897. }
  13898. };
  13899. /**
  13900. * Releases all associated resources
  13901. */
  13902. Control3D.prototype.dispose = function () {
  13903. this.onPointerDownObservable.clear();
  13904. this.onPointerEnterObservable.clear();
  13905. this.onPointerMoveObservable.clear();
  13906. this.onPointerOutObservable.clear();
  13907. this.onPointerUpObservable.clear();
  13908. this.onPointerClickObservable.clear();
  13909. this._disposeNode();
  13910. // Behaviors
  13911. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13912. var behavior = _a[_i];
  13913. behavior.detach();
  13914. }
  13915. };
  13916. return Control3D;
  13917. }());
  13918. /***/ }),
  13919. /***/ "./3D/controls/cylinderPanel.ts":
  13920. /*!**************************************!*\
  13921. !*** ./3D/controls/cylinderPanel.ts ***!
  13922. \**************************************/
  13923. /*! exports provided: CylinderPanel */
  13924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13925. "use strict";
  13926. __webpack_require__.r(__webpack_exports__);
  13927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13928. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13929. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13930. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13931. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13932. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13933. /**
  13934. * Class used to create a container panel deployed on the surface of a cylinder
  13935. */
  13936. var CylinderPanel = /** @class */ (function (_super) {
  13937. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  13938. function CylinderPanel() {
  13939. var _this = _super !== null && _super.apply(this, arguments) || this;
  13940. _this._radius = 5.0;
  13941. return _this;
  13942. }
  13943. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13944. /**
  13945. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13946. */
  13947. get: function () {
  13948. return this._radius;
  13949. },
  13950. set: function (value) {
  13951. var _this = this;
  13952. if (this._radius === value) {
  13953. return;
  13954. }
  13955. this._radius = value;
  13956. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13957. _this._arrangeChildren();
  13958. });
  13959. },
  13960. enumerable: true,
  13961. configurable: true
  13962. });
  13963. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13964. var mesh = control.mesh;
  13965. if (!mesh) {
  13966. return;
  13967. }
  13968. var newPos = this._cylindricalMapping(nodePosition);
  13969. control.position = newPos;
  13970. switch (this.orientation) {
  13971. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13972. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13973. break;
  13974. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13975. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13976. break;
  13977. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13978. break;
  13979. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13980. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13981. break;
  13982. }
  13983. };
  13984. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13985. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13986. var yAngle = (source.x / this._radius);
  13987. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13988. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13989. };
  13990. return CylinderPanel;
  13991. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13992. /***/ }),
  13993. /***/ "./3D/controls/holographicButton.ts":
  13994. /*!******************************************!*\
  13995. !*** ./3D/controls/holographicButton.ts ***!
  13996. \******************************************/
  13997. /*! exports provided: HolographicButton */
  13998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13999. "use strict";
  14000. __webpack_require__.r(__webpack_exports__);
  14001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14003. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14004. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14005. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14006. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14007. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14008. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14009. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14010. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14011. /**
  14012. * Class used to create a holographic button in 3D
  14013. */
  14014. var HolographicButton = /** @class */ (function (_super) {
  14015. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14016. /**
  14017. * Creates a new button
  14018. * @param name defines the control name
  14019. */
  14020. function HolographicButton(name, shareMaterials) {
  14021. if (shareMaterials === void 0) { shareMaterials = true; }
  14022. var _this = _super.call(this, name) || this;
  14023. _this._shareMaterials = true;
  14024. _this._shareMaterials = shareMaterials;
  14025. // Default animations
  14026. _this.pointerEnterAnimation = function () {
  14027. if (!_this.mesh) {
  14028. return;
  14029. }
  14030. _this._frontPlate.setEnabled(true);
  14031. };
  14032. _this.pointerOutAnimation = function () {
  14033. if (!_this.mesh) {
  14034. return;
  14035. }
  14036. _this._frontPlate.setEnabled(false);
  14037. };
  14038. return _this;
  14039. }
  14040. HolographicButton.prototype._disposeTooltip = function () {
  14041. this._tooltipFade = null;
  14042. if (this._tooltipTextBlock) {
  14043. this._tooltipTextBlock.dispose();
  14044. }
  14045. if (this._tooltipTexture) {
  14046. this._tooltipTexture.dispose();
  14047. }
  14048. if (this._tooltipMesh) {
  14049. this._tooltipMesh.dispose();
  14050. }
  14051. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14052. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14053. };
  14054. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14055. get: function () {
  14056. if (this._tooltipTextBlock) {
  14057. return this._tooltipTextBlock.text;
  14058. }
  14059. return null;
  14060. },
  14061. /**
  14062. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14063. */
  14064. set: function (text) {
  14065. var _this = this;
  14066. if (!text) {
  14067. this._disposeTooltip();
  14068. return;
  14069. }
  14070. if (!this._tooltipFade) {
  14071. // Create tooltip with mesh and text
  14072. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14073. 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);
  14074. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14075. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14076. tooltipBackground.material = mat;
  14077. tooltipBackground.isPickable = false;
  14078. this._tooltipMesh.addChild(tooltipBackground);
  14079. tooltipBackground.position.z = 0.05;
  14080. this._tooltipMesh.scaling.y = 1 / 3;
  14081. this._tooltipMesh.position.y = 0.7;
  14082. this._tooltipMesh.position.z = -0.15;
  14083. this._tooltipMesh.isPickable = false;
  14084. this._tooltipMesh.parent = this._backPlate;
  14085. // Create text texture for the tooltip
  14086. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14087. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14088. this._tooltipTextBlock.scaleY = 3;
  14089. this._tooltipTextBlock.color = "white";
  14090. this._tooltipTextBlock.fontSize = 130;
  14091. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14092. // Add hover action to tooltip
  14093. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14094. this._tooltipFade.delay = 500;
  14095. this._tooltipMesh.addBehavior(this._tooltipFade);
  14096. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14097. if (_this._tooltipFade) {
  14098. _this._tooltipFade.fadeIn(true);
  14099. }
  14100. });
  14101. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14102. if (_this._tooltipFade) {
  14103. _this._tooltipFade.fadeIn(false);
  14104. }
  14105. });
  14106. }
  14107. if (this._tooltipTextBlock) {
  14108. this._tooltipTextBlock.text = text;
  14109. }
  14110. },
  14111. enumerable: true,
  14112. configurable: true
  14113. });
  14114. Object.defineProperty(HolographicButton.prototype, "text", {
  14115. /**
  14116. * Gets or sets text for the button
  14117. */
  14118. get: function () {
  14119. return this._text;
  14120. },
  14121. set: function (value) {
  14122. if (this._text === value) {
  14123. return;
  14124. }
  14125. this._text = value;
  14126. this._rebuildContent();
  14127. },
  14128. enumerable: true,
  14129. configurable: true
  14130. });
  14131. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14132. /**
  14133. * Gets or sets the image url for the button
  14134. */
  14135. get: function () {
  14136. return this._imageUrl;
  14137. },
  14138. set: function (value) {
  14139. if (this._imageUrl === value) {
  14140. return;
  14141. }
  14142. this._imageUrl = value;
  14143. this._rebuildContent();
  14144. },
  14145. enumerable: true,
  14146. configurable: true
  14147. });
  14148. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14149. /**
  14150. * Gets the back material used by this button
  14151. */
  14152. get: function () {
  14153. return this._backMaterial;
  14154. },
  14155. enumerable: true,
  14156. configurable: true
  14157. });
  14158. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14159. /**
  14160. * Gets the front material used by this button
  14161. */
  14162. get: function () {
  14163. return this._frontMaterial;
  14164. },
  14165. enumerable: true,
  14166. configurable: true
  14167. });
  14168. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14169. /**
  14170. * Gets the plate material used by this button
  14171. */
  14172. get: function () {
  14173. return this._plateMaterial;
  14174. },
  14175. enumerable: true,
  14176. configurable: true
  14177. });
  14178. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14179. /**
  14180. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14181. */
  14182. get: function () {
  14183. return this._shareMaterials;
  14184. },
  14185. enumerable: true,
  14186. configurable: true
  14187. });
  14188. HolographicButton.prototype._getTypeName = function () {
  14189. return "HolographicButton";
  14190. };
  14191. HolographicButton.prototype._rebuildContent = function () {
  14192. this._disposeFacadeTexture();
  14193. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14194. panel.isVertical = true;
  14195. if (this._imageUrl) {
  14196. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14197. image.source = this._imageUrl;
  14198. image.paddingTop = "40px";
  14199. image.height = "180px";
  14200. image.width = "100px";
  14201. image.paddingBottom = "40px";
  14202. panel.addControl(image);
  14203. }
  14204. if (this._text) {
  14205. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14206. text.text = this._text;
  14207. text.color = "white";
  14208. text.height = "30px";
  14209. text.fontSize = 24;
  14210. panel.addControl(text);
  14211. }
  14212. if (this._frontPlate) {
  14213. this.content = panel;
  14214. }
  14215. };
  14216. // Mesh association
  14217. HolographicButton.prototype._createNode = function (scene) {
  14218. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14219. width: 1.0,
  14220. height: 1.0,
  14221. depth: 0.08
  14222. }, scene);
  14223. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14224. width: 1.0,
  14225. height: 1.0,
  14226. depth: 0.08
  14227. }, scene);
  14228. this._frontPlate.parent = this._backPlate;
  14229. this._frontPlate.position.z = -0.08;
  14230. this._frontPlate.isPickable = false;
  14231. this._frontPlate.setEnabled(false);
  14232. this._textPlate = _super.prototype._createNode.call(this, scene);
  14233. this._textPlate.parent = this._backPlate;
  14234. this._textPlate.position.z = -0.08;
  14235. this._textPlate.isPickable = false;
  14236. return this._backPlate;
  14237. };
  14238. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14239. this._plateMaterial.emissiveTexture = facadeTexture;
  14240. this._plateMaterial.opacityTexture = facadeTexture;
  14241. };
  14242. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14243. var _this = this;
  14244. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14245. this._backMaterial.renderHoverLight = true;
  14246. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14247. if (pickedPoint) {
  14248. _this._backMaterial.hoverPosition = pickedPoint;
  14249. _this._backMaterial.hoverColor.a = 1.0;
  14250. }
  14251. else {
  14252. _this._backMaterial.hoverColor.a = 0;
  14253. }
  14254. });
  14255. };
  14256. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14257. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14258. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14259. this._frontMaterial.alpha = 0.5; // Additive
  14260. this._frontMaterial.renderBorders = true;
  14261. };
  14262. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14263. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14264. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14265. };
  14266. HolographicButton.prototype._affectMaterial = function (mesh) {
  14267. // Back
  14268. if (this._shareMaterials) {
  14269. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14270. this._createBackMaterial(mesh);
  14271. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14272. }
  14273. else {
  14274. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14275. }
  14276. // Front
  14277. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14278. this._createFrontMaterial(mesh);
  14279. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14280. }
  14281. else {
  14282. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14283. }
  14284. }
  14285. else {
  14286. this._createBackMaterial(mesh);
  14287. this._createFrontMaterial(mesh);
  14288. }
  14289. this._createPlateMaterial(mesh);
  14290. this._backPlate.material = this._backMaterial;
  14291. this._frontPlate.material = this._frontMaterial;
  14292. this._textPlate.material = this._plateMaterial;
  14293. this._rebuildContent();
  14294. };
  14295. /**
  14296. * Releases all associated resources
  14297. */
  14298. HolographicButton.prototype.dispose = function () {
  14299. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14300. this._disposeTooltip();
  14301. if (!this.shareMaterials) {
  14302. this._backMaterial.dispose();
  14303. this._frontMaterial.dispose();
  14304. this._plateMaterial.dispose();
  14305. if (this._pickedPointObserver) {
  14306. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14307. this._pickedPointObserver = null;
  14308. }
  14309. }
  14310. };
  14311. return HolographicButton;
  14312. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14313. /***/ }),
  14314. /***/ "./3D/controls/index.ts":
  14315. /*!******************************!*\
  14316. !*** ./3D/controls/index.ts ***!
  14317. \******************************/
  14318. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14320. "use strict";
  14321. __webpack_require__.r(__webpack_exports__);
  14322. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14324. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14326. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14328. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14330. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14332. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14334. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14336. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14338. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14340. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14342. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14344. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14346. /***/ }),
  14347. /***/ "./3D/controls/meshButton3D.ts":
  14348. /*!*************************************!*\
  14349. !*** ./3D/controls/meshButton3D.ts ***!
  14350. \*************************************/
  14351. /*! exports provided: MeshButton3D */
  14352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14353. "use strict";
  14354. __webpack_require__.r(__webpack_exports__);
  14355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14356. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14357. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14358. /**
  14359. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14360. */
  14361. var MeshButton3D = /** @class */ (function (_super) {
  14362. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14363. /**
  14364. * Creates a new 3D button based on a mesh
  14365. * @param mesh mesh to become a 3D button
  14366. * @param name defines the control name
  14367. */
  14368. function MeshButton3D(mesh, name) {
  14369. var _this = _super.call(this, name) || this;
  14370. _this._currentMesh = mesh;
  14371. /**
  14372. * Provides a default behavior on hover/out & up/down
  14373. * Override those function to create your own desired behavior specific to your mesh
  14374. */
  14375. _this.pointerEnterAnimation = function () {
  14376. if (!_this.mesh) {
  14377. return;
  14378. }
  14379. _this.mesh.scaling.scaleInPlace(1.1);
  14380. };
  14381. _this.pointerOutAnimation = function () {
  14382. if (!_this.mesh) {
  14383. return;
  14384. }
  14385. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14386. };
  14387. _this.pointerDownAnimation = function () {
  14388. if (!_this.mesh) {
  14389. return;
  14390. }
  14391. _this.mesh.scaling.scaleInPlace(0.95);
  14392. };
  14393. _this.pointerUpAnimation = function () {
  14394. if (!_this.mesh) {
  14395. return;
  14396. }
  14397. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14398. };
  14399. return _this;
  14400. }
  14401. MeshButton3D.prototype._getTypeName = function () {
  14402. return "MeshButton3D";
  14403. };
  14404. // Mesh association
  14405. MeshButton3D.prototype._createNode = function (scene) {
  14406. var _this = this;
  14407. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14408. mesh.metadata = _this;
  14409. });
  14410. return this._currentMesh;
  14411. };
  14412. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14413. };
  14414. return MeshButton3D;
  14415. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14416. /***/ }),
  14417. /***/ "./3D/controls/planePanel.ts":
  14418. /*!***********************************!*\
  14419. !*** ./3D/controls/planePanel.ts ***!
  14420. \***********************************/
  14421. /*! exports provided: PlanePanel */
  14422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14423. "use strict";
  14424. __webpack_require__.r(__webpack_exports__);
  14425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14427. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14428. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14429. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14430. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14431. /**
  14432. * Class used to create a container panel deployed on the surface of a plane
  14433. */
  14434. var PlanePanel = /** @class */ (function (_super) {
  14435. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14436. function PlanePanel() {
  14437. return _super !== null && _super.apply(this, arguments) || this;
  14438. }
  14439. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14440. var mesh = control.mesh;
  14441. if (!mesh) {
  14442. return;
  14443. }
  14444. control.position = nodePosition.clone();
  14445. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14446. target.copyFrom(nodePosition);
  14447. switch (this.orientation) {
  14448. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14449. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14450. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14451. mesh.lookAt(target);
  14452. break;
  14453. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14454. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14455. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14456. mesh.lookAt(target);
  14457. break;
  14458. }
  14459. };
  14460. return PlanePanel;
  14461. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14462. /***/ }),
  14463. /***/ "./3D/controls/scatterPanel.ts":
  14464. /*!*************************************!*\
  14465. !*** ./3D/controls/scatterPanel.ts ***!
  14466. \*************************************/
  14467. /*! exports provided: ScatterPanel */
  14468. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14469. "use strict";
  14470. __webpack_require__.r(__webpack_exports__);
  14471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14473. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14474. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14475. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14476. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14477. /**
  14478. * Class used to create a container panel where items get randomized planar mapping
  14479. */
  14480. var ScatterPanel = /** @class */ (function (_super) {
  14481. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  14482. function ScatterPanel() {
  14483. var _this = _super !== null && _super.apply(this, arguments) || this;
  14484. _this._iteration = 100.0;
  14485. return _this;
  14486. }
  14487. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14488. /**
  14489. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14490. */
  14491. get: function () {
  14492. return this._iteration;
  14493. },
  14494. set: function (value) {
  14495. var _this = this;
  14496. if (this._iteration === value) {
  14497. return;
  14498. }
  14499. this._iteration = value;
  14500. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14501. _this._arrangeChildren();
  14502. });
  14503. },
  14504. enumerable: true,
  14505. configurable: true
  14506. });
  14507. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14508. var mesh = control.mesh;
  14509. var newPos = this._scatterMapping(nodePosition);
  14510. if (!mesh) {
  14511. return;
  14512. }
  14513. switch (this.orientation) {
  14514. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14515. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14516. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14517. break;
  14518. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14519. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14520. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14521. break;
  14522. }
  14523. control.position = newPos;
  14524. };
  14525. ScatterPanel.prototype._scatterMapping = function (source) {
  14526. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14527. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14528. return source;
  14529. };
  14530. ScatterPanel.prototype._finalProcessing = function () {
  14531. var meshes = [];
  14532. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14533. var child = _a[_i];
  14534. if (!child.mesh) {
  14535. continue;
  14536. }
  14537. meshes.push(child.mesh);
  14538. }
  14539. for (var count = 0; count < this._iteration; count++) {
  14540. meshes.sort(function (a, b) {
  14541. var distance1 = a.position.lengthSquared();
  14542. var distance2 = b.position.lengthSquared();
  14543. if (distance1 < distance2) {
  14544. return 1;
  14545. }
  14546. else if (distance1 > distance2) {
  14547. return -1;
  14548. }
  14549. return 0;
  14550. });
  14551. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14552. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14553. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14554. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14555. for (var i = 0; i < meshes.length - 1; i++) {
  14556. for (var j = i + 1; j < meshes.length; j++) {
  14557. if (i != j) {
  14558. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14559. // Ignore Z axis
  14560. difference2D.x = difference.x;
  14561. difference2D.y = difference.y;
  14562. var combinedRadius = cellSize;
  14563. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14564. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14565. distance -= minSeparation;
  14566. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14567. difference2D.normalize();
  14568. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14569. meshes[j].position.addInPlace(difference);
  14570. meshes[i].position.subtractInPlace(difference);
  14571. }
  14572. }
  14573. }
  14574. }
  14575. }
  14576. };
  14577. return ScatterPanel;
  14578. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14579. /***/ }),
  14580. /***/ "./3D/controls/spherePanel.ts":
  14581. /*!************************************!*\
  14582. !*** ./3D/controls/spherePanel.ts ***!
  14583. \************************************/
  14584. /*! exports provided: SpherePanel */
  14585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14586. "use strict";
  14587. __webpack_require__.r(__webpack_exports__);
  14588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14590. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14591. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14592. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14593. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14594. /**
  14595. * Class used to create a container panel deployed on the surface of a sphere
  14596. */
  14597. var SpherePanel = /** @class */ (function (_super) {
  14598. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  14599. function SpherePanel() {
  14600. var _this = _super !== null && _super.apply(this, arguments) || this;
  14601. _this._radius = 5.0;
  14602. return _this;
  14603. }
  14604. Object.defineProperty(SpherePanel.prototype, "radius", {
  14605. /**
  14606. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14607. */
  14608. get: function () {
  14609. return this._radius;
  14610. },
  14611. set: function (value) {
  14612. var _this = this;
  14613. if (this._radius === value) {
  14614. return;
  14615. }
  14616. this._radius = value;
  14617. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14618. _this._arrangeChildren();
  14619. });
  14620. },
  14621. enumerable: true,
  14622. configurable: true
  14623. });
  14624. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  14625. var mesh = control.mesh;
  14626. if (!mesh) {
  14627. return;
  14628. }
  14629. var newPos = this._sphericalMapping(nodePosition);
  14630. control.position = newPos;
  14631. switch (this.orientation) {
  14632. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14633. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  14634. break;
  14635. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14636. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  14637. break;
  14638. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14639. break;
  14640. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14641. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14642. break;
  14643. }
  14644. };
  14645. SpherePanel.prototype._sphericalMapping = function (source) {
  14646. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  14647. var xAngle = (source.y / this._radius);
  14648. var yAngle = -(source.x / this._radius);
  14649. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14650. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14651. };
  14652. return SpherePanel;
  14653. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14654. /***/ }),
  14655. /***/ "./3D/controls/stackPanel3D.ts":
  14656. /*!*************************************!*\
  14657. !*** ./3D/controls/stackPanel3D.ts ***!
  14658. \*************************************/
  14659. /*! exports provided: StackPanel3D */
  14660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14661. "use strict";
  14662. __webpack_require__.r(__webpack_exports__);
  14663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  14664. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14665. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14666. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14667. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14668. /**
  14669. * Class used to create a stack panel in 3D on XY plane
  14670. */
  14671. var StackPanel3D = /** @class */ (function (_super) {
  14672. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  14673. /**
  14674. * Creates new StackPanel
  14675. * @param isVertical
  14676. */
  14677. function StackPanel3D(isVertical) {
  14678. if (isVertical === void 0) { isVertical = false; }
  14679. var _this = _super.call(this) || this;
  14680. _this._isVertical = false;
  14681. /**
  14682. * Gets or sets the distance between elements
  14683. */
  14684. _this.margin = 0.1;
  14685. _this._isVertical = isVertical;
  14686. return _this;
  14687. }
  14688. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  14689. /**
  14690. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  14691. */
  14692. get: function () {
  14693. return this._isVertical;
  14694. },
  14695. set: function (value) {
  14696. var _this = this;
  14697. if (this._isVertical === value) {
  14698. return;
  14699. }
  14700. this._isVertical = value;
  14701. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14702. _this._arrangeChildren();
  14703. });
  14704. },
  14705. enumerable: true,
  14706. configurable: true
  14707. });
  14708. StackPanel3D.prototype._arrangeChildren = function () {
  14709. var width = 0;
  14710. var height = 0;
  14711. var controlCount = 0;
  14712. var extendSizes = [];
  14713. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14714. // Measure
  14715. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14716. var child = _a[_i];
  14717. if (!child.mesh) {
  14718. continue;
  14719. }
  14720. controlCount++;
  14721. child.mesh.computeWorldMatrix(true);
  14722. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14723. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14724. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14725. extendSizes.push(extendSize);
  14726. if (this._isVertical) {
  14727. height += extendSize.y;
  14728. }
  14729. else {
  14730. width += extendSize.x;
  14731. }
  14732. }
  14733. if (this._isVertical) {
  14734. height += (controlCount - 1) * this.margin / 2;
  14735. }
  14736. else {
  14737. width += (controlCount - 1) * this.margin / 2;
  14738. }
  14739. // Arrange
  14740. var offset;
  14741. if (this._isVertical) {
  14742. offset = -height;
  14743. }
  14744. else {
  14745. offset = -width;
  14746. }
  14747. var index = 0;
  14748. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14749. var child = _c[_b];
  14750. if (!child.mesh) {
  14751. continue;
  14752. }
  14753. controlCount--;
  14754. var extendSize = extendSizes[index++];
  14755. if (this._isVertical) {
  14756. child.position.y = offset + extendSize.y;
  14757. child.position.x = 0;
  14758. offset += extendSize.y * 2;
  14759. }
  14760. else {
  14761. child.position.x = offset + extendSize.x;
  14762. child.position.y = 0;
  14763. offset += extendSize.x * 2;
  14764. }
  14765. offset += (controlCount > 0 ? this.margin : 0);
  14766. }
  14767. };
  14768. return StackPanel3D;
  14769. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14770. /***/ }),
  14771. /***/ "./3D/controls/volumeBasedPanel.ts":
  14772. /*!*****************************************!*\
  14773. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14774. \*****************************************/
  14775. /*! exports provided: VolumeBasedPanel */
  14776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14777. "use strict";
  14778. __webpack_require__.r(__webpack_exports__);
  14779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14780. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14781. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14782. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14783. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14784. /**
  14785. * Abstract class used to create a container panel deployed on the surface of a volume
  14786. */
  14787. var VolumeBasedPanel = /** @class */ (function (_super) {
  14788. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  14789. /**
  14790. * Creates new VolumeBasedPanel
  14791. */
  14792. function VolumeBasedPanel() {
  14793. var _this = _super.call(this) || this;
  14794. _this._columns = 10;
  14795. _this._rows = 0;
  14796. _this._rowThenColum = true;
  14797. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14798. /**
  14799. * Gets or sets the distance between elements
  14800. */
  14801. _this.margin = 0;
  14802. return _this;
  14803. }
  14804. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14805. /**
  14806. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14807. * | Value | Type | Description |
  14808. * | ----- | ----------------------------------- | ----------- |
  14809. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14810. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14811. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14812. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14813. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14814. */
  14815. get: function () {
  14816. return this._orientation;
  14817. },
  14818. set: function (value) {
  14819. var _this = this;
  14820. if (this._orientation === value) {
  14821. return;
  14822. }
  14823. this._orientation = value;
  14824. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14825. _this._arrangeChildren();
  14826. });
  14827. },
  14828. enumerable: true,
  14829. configurable: true
  14830. });
  14831. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14832. /**
  14833. * Gets or sets the number of columns requested (10 by default).
  14834. * The panel will automatically compute the number of rows based on number of child controls.
  14835. */
  14836. get: function () {
  14837. return this._columns;
  14838. },
  14839. set: function (value) {
  14840. var _this = this;
  14841. if (this._columns === value) {
  14842. return;
  14843. }
  14844. this._columns = value;
  14845. this._rowThenColum = true;
  14846. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14847. _this._arrangeChildren();
  14848. });
  14849. },
  14850. enumerable: true,
  14851. configurable: true
  14852. });
  14853. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14854. /**
  14855. * Gets or sets a the number of rows requested.
  14856. * The panel will automatically compute the number of columns based on number of child controls.
  14857. */
  14858. get: function () {
  14859. return this._rows;
  14860. },
  14861. set: function (value) {
  14862. var _this = this;
  14863. if (this._rows === value) {
  14864. return;
  14865. }
  14866. this._rows = value;
  14867. this._rowThenColum = false;
  14868. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14869. _this._arrangeChildren();
  14870. });
  14871. },
  14872. enumerable: true,
  14873. configurable: true
  14874. });
  14875. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14876. this._cellWidth = 0;
  14877. this._cellHeight = 0;
  14878. var rows = 0;
  14879. var columns = 0;
  14880. var controlCount = 0;
  14881. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14882. // Measure
  14883. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14884. var child = _a[_i];
  14885. if (!child.mesh) {
  14886. continue;
  14887. }
  14888. controlCount++;
  14889. child.mesh.computeWorldMatrix(true);
  14890. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14891. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14892. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14893. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14894. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14895. diff.scaleInPlace(0.5);
  14896. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14897. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14898. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14899. }
  14900. this._cellWidth += this.margin * 2;
  14901. this._cellHeight += this.margin * 2;
  14902. // Arrange
  14903. if (this._rowThenColum) {
  14904. columns = this._columns;
  14905. rows = Math.ceil(controlCount / this._columns);
  14906. }
  14907. else {
  14908. rows = this._rows;
  14909. columns = Math.ceil(controlCount / this._rows);
  14910. }
  14911. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14912. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14913. var nodeGrid = [];
  14914. var cellCounter = 0;
  14915. if (this._rowThenColum) {
  14916. for (var r = 0; r < rows; r++) {
  14917. for (var c = 0; c < columns; c++) {
  14918. 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));
  14919. cellCounter++;
  14920. if (cellCounter > controlCount) {
  14921. break;
  14922. }
  14923. }
  14924. }
  14925. }
  14926. else {
  14927. for (var c = 0; c < columns; c++) {
  14928. for (var r = 0; r < rows; r++) {
  14929. 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));
  14930. cellCounter++;
  14931. if (cellCounter > controlCount) {
  14932. break;
  14933. }
  14934. }
  14935. }
  14936. }
  14937. cellCounter = 0;
  14938. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14939. var child = _c[_b];
  14940. if (!child.mesh) {
  14941. continue;
  14942. }
  14943. this._mapGridNode(child, nodeGrid[cellCounter]);
  14944. cellCounter++;
  14945. }
  14946. this._finalProcessing();
  14947. };
  14948. /** Child classes can implement this function to provide additional processing */
  14949. VolumeBasedPanel.prototype._finalProcessing = function () {
  14950. };
  14951. return VolumeBasedPanel;
  14952. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14953. /***/ }),
  14954. /***/ "./3D/gui3DManager.ts":
  14955. /*!****************************!*\
  14956. !*** ./3D/gui3DManager.ts ***!
  14957. \****************************/
  14958. /*! exports provided: GUI3DManager */
  14959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14960. "use strict";
  14961. __webpack_require__.r(__webpack_exports__);
  14962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14963. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  14964. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14965. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14966. /**
  14967. * Class used to manage 3D user interface
  14968. * @see http://doc.babylonjs.com/how_to/gui3d
  14969. */
  14970. var GUI3DManager = /** @class */ (function () {
  14971. /**
  14972. * Creates a new GUI3DManager
  14973. * @param scene
  14974. */
  14975. function GUI3DManager(scene) {
  14976. var _this = this;
  14977. /** @hidden */
  14978. this._lastControlOver = {};
  14979. /** @hidden */
  14980. this._lastControlDown = {};
  14981. /**
  14982. * Observable raised when the point picked by the pointer events changed
  14983. */
  14984. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14985. // Shared resources
  14986. /** @hidden */
  14987. this._sharedMaterials = {};
  14988. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14989. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14990. _this._sceneDisposeObserver = null;
  14991. _this._utilityLayer = null;
  14992. _this.dispose();
  14993. });
  14994. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14995. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14996. this._utilityLayer.pickUtilitySceneFirst = false;
  14997. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14998. return mesh && mesh.metadata && mesh.metadata._node;
  14999. };
  15000. // Root
  15001. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15002. this._rootContainer._host = this;
  15003. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15004. // Events
  15005. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15006. _this._handlePointerOut(pointerId, true);
  15007. });
  15008. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15009. _this._doPicking(pi);
  15010. });
  15011. // Scene
  15012. this._utilityLayer.utilityLayerScene.autoClear = false;
  15013. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15014. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15015. }
  15016. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15017. /** Gets the hosting scene */
  15018. get: function () {
  15019. return this._scene;
  15020. },
  15021. enumerable: true,
  15022. configurable: true
  15023. });
  15024. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15025. /** Gets associated utility layer */
  15026. get: function () {
  15027. return this._utilityLayer;
  15028. },
  15029. enumerable: true,
  15030. configurable: true
  15031. });
  15032. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15033. var previousControlOver = this._lastControlOver[pointerId];
  15034. if (previousControlOver) {
  15035. previousControlOver._onPointerOut(previousControlOver);
  15036. delete this._lastControlOver[pointerId];
  15037. }
  15038. if (isPointerUp) {
  15039. if (this._lastControlDown[pointerId]) {
  15040. this._lastControlDown[pointerId].forcePointerUp();
  15041. delete this._lastControlDown[pointerId];
  15042. }
  15043. }
  15044. this.onPickedPointChangedObservable.notifyObservers(null);
  15045. };
  15046. GUI3DManager.prototype._doPicking = function (pi) {
  15047. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15048. return false;
  15049. }
  15050. var pointerEvent = (pi.event);
  15051. var pointerId = pointerEvent.pointerId || 0;
  15052. var buttonIndex = pointerEvent.button;
  15053. var pickingInfo = pi.pickInfo;
  15054. if (!pickingInfo || !pickingInfo.hit) {
  15055. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15056. return false;
  15057. }
  15058. var control = (pickingInfo.pickedMesh.metadata);
  15059. if (pickingInfo.pickedPoint) {
  15060. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15061. }
  15062. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15063. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15064. if (this._lastControlOver[pointerId]) {
  15065. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15066. }
  15067. delete this._lastControlOver[pointerId];
  15068. }
  15069. }
  15070. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15071. if (this._lastControlDown[pointerEvent.pointerId]) {
  15072. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15073. delete this._lastControlDown[pointerEvent.pointerId];
  15074. }
  15075. if (pointerEvent.pointerType === "touch") {
  15076. this._handlePointerOut(pointerId, false);
  15077. }
  15078. }
  15079. return true;
  15080. };
  15081. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15082. /**
  15083. * Gets the root container
  15084. */
  15085. get: function () {
  15086. return this._rootContainer;
  15087. },
  15088. enumerable: true,
  15089. configurable: true
  15090. });
  15091. /**
  15092. * Gets a boolean indicating if the given control is in the root child list
  15093. * @param control defines the control to check
  15094. * @returns true if the control is in the root child list
  15095. */
  15096. GUI3DManager.prototype.containsControl = function (control) {
  15097. return this._rootContainer.containsControl(control);
  15098. };
  15099. /**
  15100. * Adds a control to the root child list
  15101. * @param control defines the control to add
  15102. * @returns the current manager
  15103. */
  15104. GUI3DManager.prototype.addControl = function (control) {
  15105. this._rootContainer.addControl(control);
  15106. return this;
  15107. };
  15108. /**
  15109. * Removes a control from the root child list
  15110. * @param control defines the control to remove
  15111. * @returns the current container
  15112. */
  15113. GUI3DManager.prototype.removeControl = function (control) {
  15114. this._rootContainer.removeControl(control);
  15115. return this;
  15116. };
  15117. /**
  15118. * Releases all associated resources
  15119. */
  15120. GUI3DManager.prototype.dispose = function () {
  15121. this._rootContainer.dispose();
  15122. for (var materialName in this._sharedMaterials) {
  15123. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15124. continue;
  15125. }
  15126. this._sharedMaterials[materialName].dispose();
  15127. }
  15128. this._sharedMaterials = {};
  15129. if (this._pointerOutObserver && this._utilityLayer) {
  15130. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15131. this._pointerOutObserver = null;
  15132. }
  15133. this.onPickedPointChangedObservable.clear();
  15134. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15135. if (utilityLayerScene) {
  15136. if (this._pointerObserver) {
  15137. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15138. this._pointerObserver = null;
  15139. }
  15140. }
  15141. if (this._scene) {
  15142. if (this._sceneDisposeObserver) {
  15143. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15144. this._sceneDisposeObserver = null;
  15145. }
  15146. }
  15147. if (this._utilityLayer) {
  15148. this._utilityLayer.dispose();
  15149. }
  15150. };
  15151. return GUI3DManager;
  15152. }());
  15153. /***/ }),
  15154. /***/ "./3D/index.ts":
  15155. /*!*********************!*\
  15156. !*** ./3D/index.ts ***!
  15157. \*********************/
  15158. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15160. "use strict";
  15161. __webpack_require__.r(__webpack_exports__);
  15162. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15175. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15178. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15180. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15182. /***/ }),
  15183. /***/ "./3D/materials/fluentMaterial.ts":
  15184. /*!****************************************!*\
  15185. !*** ./3D/materials/fluentMaterial.ts ***!
  15186. \****************************************/
  15187. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15189. "use strict";
  15190. __webpack_require__.r(__webpack_exports__);
  15191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15192. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15193. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15194. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  15195. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15196. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15197. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15198. /** @hidden */
  15199. var FluentMaterialDefines = /** @class */ (function (_super) {
  15200. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15201. function FluentMaterialDefines() {
  15202. var _this = _super.call(this) || this;
  15203. _this.INNERGLOW = false;
  15204. _this.BORDER = false;
  15205. _this.HOVERLIGHT = false;
  15206. _this.TEXTURE = false;
  15207. _this.rebuild();
  15208. return _this;
  15209. }
  15210. return FluentMaterialDefines;
  15211. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15212. /**
  15213. * Class used to render controls with fluent desgin
  15214. */
  15215. var FluentMaterial = /** @class */ (function (_super) {
  15216. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15217. /**
  15218. * Creates a new Fluent material
  15219. * @param name defines the name of the material
  15220. * @param scene defines the hosting scene
  15221. */
  15222. function FluentMaterial(name, scene) {
  15223. var _this = _super.call(this, name, scene) || this;
  15224. /**
  15225. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15226. */
  15227. _this.innerGlowColorIntensity = 0.5;
  15228. /**
  15229. * Gets or sets the inner glow color (white by default)
  15230. */
  15231. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15232. /**
  15233. * Gets or sets alpha value (default is 1.0)
  15234. */
  15235. _this.alpha = 1.0;
  15236. /**
  15237. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15238. */
  15239. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15240. /**
  15241. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15242. */
  15243. _this.renderBorders = false;
  15244. /**
  15245. * Gets or sets border width (default is 0.5)
  15246. */
  15247. _this.borderWidth = 0.5;
  15248. /**
  15249. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15250. */
  15251. _this.edgeSmoothingValue = 0.02;
  15252. /**
  15253. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15254. */
  15255. _this.borderMinValue = 0.1;
  15256. /**
  15257. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15258. */
  15259. _this.renderHoverLight = false;
  15260. /**
  15261. * Gets or sets the radius used to render the hover light (default is 1.0)
  15262. */
  15263. _this.hoverRadius = 1.0;
  15264. /**
  15265. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15266. */
  15267. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15268. /**
  15269. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15270. */
  15271. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15272. return _this;
  15273. }
  15274. FluentMaterial.prototype.needAlphaBlending = function () {
  15275. return this.alpha !== 1.0;
  15276. };
  15277. FluentMaterial.prototype.needAlphaTesting = function () {
  15278. return false;
  15279. };
  15280. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15281. return null;
  15282. };
  15283. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15284. if (this.isFrozen) {
  15285. if (this._wasPreviouslyReady && subMesh.effect) {
  15286. return true;
  15287. }
  15288. }
  15289. if (!subMesh._materialDefines) {
  15290. subMesh._materialDefines = new FluentMaterialDefines();
  15291. }
  15292. var scene = this.getScene();
  15293. var defines = subMesh._materialDefines;
  15294. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15295. if (defines._renderId === scene.getRenderId()) {
  15296. return true;
  15297. }
  15298. }
  15299. if (defines._areTexturesDirty) {
  15300. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15301. defines.BORDER = this.renderBorders;
  15302. defines.HOVERLIGHT = this.renderHoverLight;
  15303. if (this._albedoTexture) {
  15304. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15305. return false;
  15306. }
  15307. else {
  15308. defines.TEXTURE = true;
  15309. }
  15310. }
  15311. else {
  15312. defines.TEXTURE = false;
  15313. }
  15314. }
  15315. var engine = scene.getEngine();
  15316. // Get correct effect
  15317. if (defines.isDirty) {
  15318. defines.markAsProcessed();
  15319. scene.resetCachedMaterial();
  15320. //Attributes
  15321. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15322. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15323. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15324. var shaderName = "fluent";
  15325. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15326. "hoverColor", "hoverPosition", "hoverRadius"
  15327. ];
  15328. var samplers = ["albedoSampler"];
  15329. var uniformBuffers = new Array();
  15330. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15331. uniformsNames: uniforms,
  15332. uniformBuffersNames: uniformBuffers,
  15333. samplers: samplers,
  15334. defines: defines,
  15335. maxSimultaneousLights: 4
  15336. });
  15337. var join = defines.toString();
  15338. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15339. attributes: attribs,
  15340. uniformsNames: uniforms,
  15341. uniformBuffersNames: uniformBuffers,
  15342. samplers: samplers,
  15343. defines: join,
  15344. fallbacks: null,
  15345. onCompiled: this.onCompiled,
  15346. onError: this.onError,
  15347. indexParameters: { maxSimultaneousLights: 4 }
  15348. }, engine));
  15349. }
  15350. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15351. return false;
  15352. }
  15353. defines._renderId = scene.getRenderId();
  15354. this._wasPreviouslyReady = true;
  15355. return true;
  15356. };
  15357. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15358. var scene = this.getScene();
  15359. var defines = subMesh._materialDefines;
  15360. if (!defines) {
  15361. return;
  15362. }
  15363. var effect = subMesh.effect;
  15364. if (!effect) {
  15365. return;
  15366. }
  15367. this._activeEffect = effect;
  15368. // Matrices
  15369. this.bindOnlyWorldMatrix(world);
  15370. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15371. if (this._mustRebind(scene, effect)) {
  15372. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15373. if (defines.INNERGLOW) {
  15374. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15375. }
  15376. if (defines.BORDER) {
  15377. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15378. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15379. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15380. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15381. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15382. }
  15383. if (defines.HOVERLIGHT) {
  15384. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15385. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15386. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15387. }
  15388. if (defines.TEXTURE) {
  15389. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15390. }
  15391. }
  15392. this._afterBind(mesh, this._activeEffect);
  15393. };
  15394. FluentMaterial.prototype.getActiveTextures = function () {
  15395. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15396. return activeTextures;
  15397. };
  15398. FluentMaterial.prototype.hasTexture = function (texture) {
  15399. if (_super.prototype.hasTexture.call(this, texture)) {
  15400. return true;
  15401. }
  15402. return false;
  15403. };
  15404. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15405. _super.prototype.dispose.call(this, forceDisposeEffect);
  15406. };
  15407. FluentMaterial.prototype.clone = function (name) {
  15408. var _this = this;
  15409. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15410. };
  15411. FluentMaterial.prototype.serialize = function () {
  15412. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15413. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15414. return serializationObject;
  15415. };
  15416. FluentMaterial.prototype.getClassName = function () {
  15417. return "FluentMaterial";
  15418. };
  15419. // Statics
  15420. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15421. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15422. };
  15423. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15424. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15425. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15426. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15427. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15428. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15429. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15430. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15431. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15432. ], FluentMaterial.prototype, "alpha", void 0);
  15433. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15434. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15435. ], FluentMaterial.prototype, "albedoColor", void 0);
  15436. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15437. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15438. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15439. ], FluentMaterial.prototype, "renderBorders", void 0);
  15440. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15441. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15442. ], FluentMaterial.prototype, "borderWidth", void 0);
  15443. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15444. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15445. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15446. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15447. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15448. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15449. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15450. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15451. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15452. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15453. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15454. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15455. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15456. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15457. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15458. ], FluentMaterial.prototype, "hoverColor", void 0);
  15459. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15460. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15461. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15462. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15463. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15464. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15465. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15466. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15467. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15468. return FluentMaterial;
  15469. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15470. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15471. /***/ }),
  15472. /***/ "./3D/materials/index.ts":
  15473. /*!*******************************!*\
  15474. !*** ./3D/materials/index.ts ***!
  15475. \*******************************/
  15476. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15478. "use strict";
  15479. __webpack_require__.r(__webpack_exports__);
  15480. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15483. /***/ }),
  15484. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15485. /*!*************************************************!*\
  15486. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15487. \*************************************************/
  15488. /*! exports provided: fluentPixelShader */
  15489. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15490. "use strict";
  15491. __webpack_require__.r(__webpack_exports__);
  15492. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15493. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15494. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15495. var name = 'fluentPixelShader';
  15496. 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}";
  15497. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15498. /** @hidden */
  15499. var fluentPixelShader = { name: name, shader: shader };
  15500. /***/ }),
  15501. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15502. /*!***********************************************!*\
  15503. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15504. \***********************************************/
  15505. /*! exports provided: fluentVertexShader */
  15506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15507. "use strict";
  15508. __webpack_require__.r(__webpack_exports__);
  15509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15510. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15511. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15512. var name = 'fluentVertexShader';
  15513. 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";
  15514. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15515. /** @hidden */
  15516. var fluentVertexShader = { name: name, shader: shader };
  15517. /***/ }),
  15518. /***/ "./3D/vector3WithInfo.ts":
  15519. /*!*******************************!*\
  15520. !*** ./3D/vector3WithInfo.ts ***!
  15521. \*******************************/
  15522. /*! exports provided: Vector3WithInfo */
  15523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15524. "use strict";
  15525. __webpack_require__.r(__webpack_exports__);
  15526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15527. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15528. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  15529. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15530. /**
  15531. * Class used to transport Vector3 information for pointer events
  15532. */
  15533. var Vector3WithInfo = /** @class */ (function (_super) {
  15534. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  15535. /**
  15536. * Creates a new Vector3WithInfo
  15537. * @param source defines the vector3 data to transport
  15538. * @param buttonIndex defines the current mouse button index
  15539. */
  15540. function Vector3WithInfo(source,
  15541. /** defines the current mouse button index */
  15542. buttonIndex) {
  15543. if (buttonIndex === void 0) { buttonIndex = 0; }
  15544. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15545. _this.buttonIndex = buttonIndex;
  15546. return _this;
  15547. }
  15548. return Vector3WithInfo;
  15549. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15550. /***/ }),
  15551. /***/ "./index.ts":
  15552. /*!******************!*\
  15553. !*** ./index.ts ***!
  15554. \******************/
  15555. /*! 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, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15557. "use strict";
  15558. __webpack_require__.r(__webpack_exports__);
  15559. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15601. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  15610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  15611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  15612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  15613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  15614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  15615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  15616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15618. /***/ }),
  15619. /***/ "./legacy/legacy.ts":
  15620. /*!**************************!*\
  15621. !*** ./legacy/legacy.ts ***!
  15622. \**************************/
  15623. /*! 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, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15625. "use strict";
  15626. __webpack_require__.r(__webpack_exports__);
  15627. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  15628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  15638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  15639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15685. /**
  15686. * Legacy support, defining window.BABYLON.GUI (global variable).
  15687. *
  15688. * This is the entry point for the UMD module.
  15689. * The entry point for a future ESM package should be index.ts
  15690. */
  15691. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  15692. if (typeof globalObject !== "undefined") {
  15693. globalObject.BABYLON = globalObject.BABYLON || {};
  15694. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  15695. }
  15696. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  15697. /***/ }),
  15698. /***/ "babylonjs/Maths/math":
  15699. /*!****************************************************************************************************!*\
  15700. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  15701. \****************************************************************************************************/
  15702. /*! no static exports found */
  15703. /***/ (function(module, exports) {
  15704. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  15705. /***/ })
  15706. /******/ });
  15707. });
  15708. //# sourceMappingURL=babylon.gui.js.map